/********************************************************************************/
/*   The  Software  is  proprietary,  confidential,  and  valuable to Realtek   */
/*   Semiconductor  Corporation  ("Realtek").  All  rights, including but not   */
/*   limited  to  copyrights,  patents,  trademarks, trade secrets, mask work   */
/*   rights, and other similar rights and interests, are reserved to Realtek.   */
/*   Without  prior  written  consent  from  Realtek,  copying, reproduction,   */
/*   modification,  distribution,  or  otherwise  is strictly prohibited. The   */
/*   Software  shall  be  kept  strictly  in  confidence,  and  shall  not be   */
/*   disclosed to or otherwise accessed by any third party.                     */
/*   c<2003> - <2012>                                                           */
/*   The Software is provided "AS IS" without any warranty of any kind,         */
/*   express, implied, statutory or otherwise.                                  */
/********************************************************************************/

//----------------------------------------------------------------------------------------------------
// ID Code      : RTD2014Osd.c No.0000
// Update Note  :
//----------------------------------------------------------------------------------------------------

#define __KEC_OSD__

#include "UserCommonInclude.h"

#if(_OSD_TYPE == _KEC_OSD)

//****************************************************************************
// DEFINITIONS / MACROS
//****************************************************************************
#define _PSW_CNT			3

BYTE code tServiceLevel2Password[] = 
{
	_LEFT_KEY_MESSAGE,
	_RIGHT_KEY_MESSAGE,
    _RIGHT_KEY_MESSAGE,
};
#if(_USE_BATTERY)
bit bDrawBattery    		= _FALSE;
BYTE bBatteryStatus    		= 0xFF;
BYTE bBatteryPreStatus    	= 0xFF;
#endif
//****************************************************************************
// STRUCT / TYPE / ENUM DEFINITTIONS
//****************************************************************************


//****************************************************************************
// CODE TABLES
//****************************************************************************


//****************************************************************************
// VARIABLE DECLARATIONS
//****************************************************************************
StructOsdInfo g_stOsdInfo;

WORD g_usAdjustValue;
WORD g_usBackupValue;
BYTE g_ucBackupFacValue;
BYTE g_ucLogoTimerCounter;

WORD ucStartItem = 0;
WORD ucEndItem   = 0;
BYTE ucCurrRow 	 = 0;

bit ucEnterServiceLevel_flag = 0;    
//****************************************************************************
// FUNCTION DECLARATIONS
//****************************************************************************
void UserOsdHandler(void);
void RTDOsdSystemFlowProc(void);
void RTDOsdEventMsgProc(void);
void KECHotKeyStatusProcess(void);
void UserKeyConvert(void);


//***************************************************************************
// FUNCTION DEFINITIONS
//****************************************************************************
//--------------------------------------------------
// Description  : OSD Handler, executed in the main loop
// Input Value  : None
// Output Value : None
//--------------------------------------------------
void UserOsdHandler(void)
{
    RTDOsdSystemFlowProc();
    RTDOsdEventMsgProc();
}

//--------------------------------------------------
// Description  : OSD system flow
// Input Value  : None
// Output Value : None
//--------------------------------------------------
void RTDOsdSystemFlowProc(void)
{
    switch(SysModeGetModeState())
    {
        case _MODE_STATUS_POWER_OFF:

            if(SysModeGetModeStateChange() == _TRUE)
            {
                SET_FORCE_POW_SAV_STATUS(_FALSE);
            }

            break;

        case _MODE_STATUS_INITIAL:

            if(SysModeGetModeStateChange() == _TRUE)
            {
#if(_FREESYNC_OD_MEASURE == _ON)
                UserAdjustFREESYNCODMeasure();
#endif
				#if(_ENCRYPTION_OPTION)
					sha204_check_status();
				#endif

				#if(_POWER_ON_LOGO_EN)
                OsdDispShowLogo();
				#endif
				
				#if((_POWER_ON_LOGO_EN) ||(_PRODUCT_ID_SEL == PRODUCT_ID_DEMO_CDB01_D_LVDS_G286HAN01))
                UserCommonInterfacePanelPowerAction(_BACKLIGHT_ON);
				#endif

				#if(_POWER_ON_LOGO_EN)
                ScalerTimerActiveTimerEvent(SEC(3), _USER_TIMER_EVENT_OSD_DISABLE_OSD_LOGO);
				#endif
            }

            break;

        case _MODE_STATUS_SEARCH:

            if(SysModeGetModeStateChange() == _TRUE)
            {
#if(_FREEZE_SUPPORT == _ON)
                if(GET_OSD_FREEZE_STATUS() == _ON)
                {
                    SET_OSD_FREEZE_STATUS(_OFF);
                }
#endif
                if(SysPowerGetPowerStatus() == _POWER_STATUS_NORMAL)
                {
                    UserInterfaceKeyPadLedControl(_LED_POWER_SEARCH);
                }
            }

            break;

        case _MODE_STATUS_DISPLAY_SETTING:

            break;

        case _MODE_STATUS_ACTIVE:

            if(SysModeGetModeStateChange() == _TRUE)
            {
                if(SysPowerGetPowerStatus() == _POWER_STATUS_NORMAL)
                {
                    UserInterfaceKeyPadLedControl(_LED_POWER_ACTIVE);
                }
            }

            break;

        case _MODE_STATUS_NOSUPPORT:

            if(SysModeGetModeStateChange() == _TRUE)
            {
                if(SysPowerGetPowerStatus() == _POWER_STATUS_NORMAL)
                {
                    SET_OSD_EVENT_MESSAGE(_OSDEVENT_SHOW_NOSUPPORT_MSG);
                    UserInterfaceKeyPadLedControl(_LED_POWER_NOSUPPORT);
                }
            }

            break;

        case _MODE_STATUS_NOSIGNAL:

            if(SysModeGetModeStateChange() == _TRUE)
            {
                if(SysSourceGetCableDetect(UserCommonNVRamGetSystemData(_SEARCH_PORT)) == _TRUE)
                {
                    ScalerTimerActiveTimerEvent(SEC(2), _USER_TIMER_EVENT_OSD_SHOW_NO_SIGNAL);
                }
                else
                {
                    ScalerTimerActiveTimerEvent(SEC(2), _USER_TIMER_EVENT_OSD_SHOW_NO_CABLE);
                }
            }

            break;

        case _MODE_STATUS_POWER_SAVING:

            if(SysSourceGetCableDetect(SysSourceGetInputPort()) == _FALSE)
            {
                SET_FORCE_POW_SAV_STATUS(_FALSE);
            }

            if(SysPowerGetPowerStatus() == _POWER_STATUS_NORMAL)
            {
                if(GET_OSD_POWER_SAVING_SHOW_SOURCE() == _TRUE)
                {
                    SET_OSD_POWER_SAVING_SHOW_SOURCE(_FALSE);

                    SET_OSD_EVENT_MESSAGE(_OSDEVENT_SHOW_CHANGE_SOURCE_MENU_MSG);
                }
                else if(GET_OSD_WAKE_UP_SWITCH_DDCCI_PORT() == _TRUE)
                {
                    SET_OSD_WAKE_UP_SWITCH_DDCCI_PORT(_FALSE);

                    SET_OSD_EVENT_MESSAGE(_OSDEVENT_WAKE_UP_SWITCH_DDCCI_PORT_MSG);
                }
#if(_DP_SUPPORT == _ON)
                else if(GET_OSD_POWER_SAVING_SHOW_DP_OPTION() == _TRUE)
                {
                    SET_OSD_POWER_SAVING_SHOW_DP_OPTION(_FALSE);
                    SET_OSD_EVENT_MESSAGE(_OSDEVENT_DP_VERSIOM_MSG);
                }
#endif
#if(_DP_DEBUG_MSG == _ON)
                else if(GET_OSD_POWER_SAVING_SHOW_DP_INFO() == _TRUE)
                {
                    SET_OSD_POWER_SAVING_SHOW_DP_INFO(_FALSE);

                    OsdDispOsdMessage(_OSD_DISP_INPUT_SIGNAL_MSG);
                    UserCommonInterfacePanelPowerAction(_BACKLIGHT_ON);
                }
#endif
	            else if(GET_OSD_POWER_SAVING_KEY_WAKEUP() == _TRUE)
	            {
	                SET_OSD_POWER_SAVING_KEY_WAKEUP(_FALSE);
	                SET_OSD_EVENT_MESSAGE(_OSDEVENT_WAKE_UP_KEY_MSG);
	            }
            }

            break;

        case _MODE_STATUS_FACTORY:

            break;

        default:

            break;
    }

#if(_DP_EMBEDDED_SWITCH_SUPPORT_TYPE == _DP_EMBEDDED_SWITCH_2_DP)
    // Check embedded DP switch status
    UserCommonAdjustEmbeddedDpSwitch();
#endif

    UserKeyConvert();

    if(GET_KEYMESSAGE() < _KEY_AMOUNT)
    {
        // hot key
        if((SysModeGetModeState() == _MODE_STATUS_ACTIVE) ||
           (SysModeGetModeState() == _MODE_STATUS_NOSUPPORT) ||
           (SysModeGetModeState() == _MODE_STATUS_NOSIGNAL) ||
           (SysModeGetModeState() == _MODE_STATUS_POWER_SAVING))
        {
            if((GET_OSD_STATE() != _MENU_NONE) && 
               ((GET_KEYMESSAGE() == _LEFT_KEY_MESSAGE)  || \
                (GET_KEYMESSAGE() == _RIGHT_KEY_MESSAGE) || \
                (GET_KEYMESSAGE() == _BRIGHTNESS_DEC_KEY_MESSAGE)|| \
                (GET_KEYMESSAGE() == _BRIGHTNESS_INC_KEY_MESSAGE)|| \
                (GET_KEYMESSAGE() == _VOL_DEC_KEY_MESSAGE)|| \
                (GET_KEYMESSAGE() == _VOL_INC_KEY_MESSAGE)))
            {
                SET_KEYREPEATENABLE();
            }
            
            DebugMessageSystem("osd handler ",GET_KEYMESSAGE());
            KECHotKeyStatusProcess();

        }

        if(GET_OSD_IN_FACTORY_MENU_STATUS() == _TRUE)
        {
            RTDFactoryMenuOperation();
            ScalerTimerCancelTimerEvent(_USER_TIMER_EVENT_OSD_DISABLE);
        }
        else
        {
#if(_FREEZE_SUPPORT == _ON)
#if(_URGENT_EVENT_CHECK_MODE == _ON)
            if(ScalerTimerSearchActiveTimerEvent(_USER_TIMER_EVENT_OSD_DISABLE_FREEZE_MSG) == _TRUE)
            {
                return;
            }
#else
            if(GET_FREEZE_DISABLE_MSG_STATE() == _ON)
            {
                return;
            }
#endif
#endif
            // back up previous OSD State
            SET_OSD_STATE_PREVIOUS(GET_OSD_STATE());

#if(_FREEZE_SUPPORT == _ON)
            if(GET_OSD_FREEZE_STATUS() == _ON) // Confirm whether disable the freeze status
            {
                if(OsdFuncCheckFreezeDisable() == _TRUE)
                {
                    return;
                }
            }
#endif

            /*if((GET_OSD_STATE() >= _MENU_PICTURE) && (GET_OSD_STATE() <= _MENU_COLOR_PCM_SOFT_PROFT_ADJUST))
            {
                OsdDispMainMenuKeyInfo(GET_KEYMESSAGE(), _OSD_HIGHLIGHT);
            }*/

            (*OperationTable[GET_OSD_STATE()])();
            // Clear the key message
            if(GET_KEYMESSAGE() != _HOLD_KEY_MESSAGE)
            {
                SET_KEYMESSAGE(_NONE_KEY_MESSAGE);
            }
            
            if(GET_OSD_LIGHTBOXMODE_STATUS() == _ON)
            {
                return;
            }

            if(GET_OSD_IN_FACTORY_MENU_STATUS() == _FALSE)
            {
                if(SysModeGetModeState() == _MODE_STATUS_ACTIVE)
                {
                    /*if(GET_OSD_TIME_OUT() <= 10)
                    {
                        ScalerTimerCancelTimerEvent(_USER_TIMER_EVENT_OSD_DISABLE);
                    }
                    else*/
                    {
                        ScalerTimerReactiveTimerEvent(SEC(GET_OSD_TIME_OUT()), _USER_TIMER_EVENT_OSD_DISABLE);
                    }
                }
            }


/*
            if((GET_OSD_STATE() >= _MENU_NONE) &&
                (GET_OSD_STATE() < _MENU_END) &&
                ((SysModeGetModeState() == _MODE_STATUS_POWER_SAVING) || (SysModeGetModeState() == _MODE_STATUS_NOSIGNAL)))
            {
                ScalerTimerCancelTimerEvent(_USER_TIMER_EVENT_OSD_DISABLE);
                ScalerTimerReactiveTimerEvent(SEC(3), _USER_TIMER_EVENT_OSD_SHOW_POWER_SAVING);
            }
            else//(SysModeGetModeState() == _MODE_STATUS_ACTIVE)
            {
                ScalerTimerReactiveTimerEvent(SEC(GET_OSD_TIME_OUT()), _USER_TIMER_EVENT_OSD_DISABLE);
            }

            if(GET_OSD_IN_FACTORY_MENU_STATUS())
            {
                ScalerTimerCancelTimerEvent(_USER_TIMER_EVENT_OSD_DISABLE);
            }
*/
        }
    }
}

//--------------------------------------------------
// Description  : OSD event message processing function
// Input Value  : None
// Output Value : None
//--------------------------------------------------
void RTDOsdEventMsgProc(void)
{
    switch(GET_OSD_EVENT_MESSAGE())
    {
        case _OSDEVENT_SHOW_NOSIGNAL_MSG:
            OsdDispOsdMessage(_OSD_DISP_NOSIGNAL_MSG);
            UserCommonInterfacePanelPowerAction(_BACKLIGHT_ON);
            //ScalerTimerActiveTimerEvent(SEC(3), _USER_TIMER_EVENT_OSD_SHOW_POWER_SAVING);
            break;

        case _OSDEVENT_SHOW_NOCABLE_MSG:
            OsdDispOsdMessage(_OSD_DISP_NOCABLE_MSG);
            UserCommonInterfacePanelPowerAction(_BACKLIGHT_ON);
            //ScalerTimerActiveTimerEvent(SEC(3), _USER_TIMER_EVENT_OSD_SHOW_POWER_SAVING);
            break;

        case _OSDEVENT_SHOW_NOSUPPORT_MSG:

            ScalerTimerCancelTimerEvent(_USER_TIMER_EVENT_OSD_SHOW_NO_CABLE);
            ScalerTimerCancelTimerEvent(_USER_TIMER_EVENT_OSD_SHOW_NO_SIGNAL);

            OsdDispOsdMessage(_OSD_DISP_NOSUPPORT_MSG);
            UserCommonInterfacePanelPowerAction(_BACKLIGHT_ON);
            //ScalerTimerReactiveTimerEvent(SEC(3), _USER_TIMER_EVENT_OSD_SHOW_POWER_SAVING);
            break;

        case _OSDEVENT_SHOW_FAIL_SAFE_MODE_MSG:
            OsdDispOsdMessage(_OSD_DISP_FAIL_SAFE_MODE_MSG);
            break;

		case _OSDEVENT_WAKE_UP_KEY_MSG:
            ScalerTimerCancelTimerEvent(_USER_TIMER_EVENT_GO_TO_POWER_SAVING);
            ScalerTimerCancelTimerEvent(_USER_TIMER_EVENT_OSD_SHOW_NO_CABLE);
            ScalerTimerCancelTimerEvent(_USER_TIMER_EVENT_OSD_SHOW_NO_SIGNAL);

            OsdFuncEnableOsd();
            
            if(SysSourceGetCableDetect(UserCommonNVRamGetSystemData(_SEARCH_PORT)) == _TRUE)
            {
                ScalerTimerActiveTimerEvent(SEC(2), _USER_TIMER_EVENT_OSD_SHOW_NO_SIGNAL);
            }
            else
            {
                ScalerTimerActiveTimerEvent(SEC(2), _USER_TIMER_EVENT_OSD_SHOW_NO_CABLE);
            }
            UserCommonInterfacePanelPowerAction(_BACKLIGHT_ON);


			break;
			
        case _OSDEVENT_SHOW_CHANGE_SOURCE_MENU_MSG:
            ScalerTimerCancelTimerEvent(_USER_TIMER_EVENT_GO_TO_POWER_SAVING);
            ScalerTimerCancelTimerEvent(_USER_TIMER_EVENT_OSD_SHOW_NO_CABLE);
            ScalerTimerCancelTimerEvent(_USER_TIMER_EVENT_OSD_SHOW_NO_SIGNAL);
            SET_OSD_STATE(_MENU_HOTKEY_SOURCE);
            OsdFuncSetOsdItemFlag();
            g_usBackupValue = GET_OSD_INPUT_PORT_OSD_ITEM();
            OsdDispHotKeySourceMenu();

            ScalerTimerReactiveTimerEvent(SEC(3), _USER_TIMER_EVENT_OSD_SHOW_POWER_SAVING);
            UserCommonInterfacePanelPowerAction(_BACKLIGHT_ON);
            break;

        /*case _OSDEVENT_WAKE_UP_SWITCH_DDCCI_PORT_MSG:

            ScalerTimerCancelTimerEvent(_USER_TIMER_EVENT_GO_TO_POWER_SAVING);
            ScalerTimerCancelTimerEvent(_USER_TIMER_EVENT_OSD_SHOW_NO_CABLE);
            ScalerTimerCancelTimerEvent(_USER_TIMER_EVENT_OSD_SHOW_NO_SIGNAL);
            SET_OSD_STATE(_MENU_HOTKEY_DDCCI);
            OsdDispHotKeyOptionMenu(_HOTKEY_DDCCI);
            ScalerTimerReactiveTimerEvent(SEC(3), _USER_TIMER_EVENT_OSD_SHOW_POWER_SAVING);
            UserCommonInterfacePanelPowerAction(_BACKLIGHT_ON);

            break;*/

        case _OSDEVENT_SHOW_POWER_SAVING_EVENT_MSG:
            OsdDispDisableOsd();
            OsdDispOsdMessage(_OSD_DISP_POWER_SAVING_MSG);
            UserCommonInterfacePanelPowerAction(_BACKLIGHT_ON);
            ScalerTimerActiveTimerEvent(SEC(2), _USER_TIMER_EVENT_GO_TO_POWER_SAVING);
            break;

        case _OSDEVENT_GO_TO_POWER_SAVING_EVENT_MSG:

            OsdDispDisableOsd();
            if((SysModeGetModeState() == _MODE_STATUS_NOSUPPORT) || (SysPowerGetPowerStatus() == _POWER_STATUS_NOSUPPORT_SAVING))
            {
                SysPowerSetTargetPowerStatus(_POWER_STATUS_NOSUPPORT_SAVING);
            }
            else
            {
                SysPowerSetTargetPowerStatus(_POWER_STATUS_SAVING);
            }
            break;

#if(_VGA_SUPPORT == _ON)
        case _OSDEVENT_DO_AUTO_CONFIG_MSG:
#if(_FREEZE_SUPPORT == _ON)
            ScalerTimerWaitForActiveTimerEvent(_USER_TIMER_EVENT_OSD_DISABLE_FREEZE_MSG);
#endif
            OsdDispAutoConfigProc();
            break;
#endif

        case _OSDEVENT_ACTIVE_DO_ONE_TIME_MSG:

#if(_FREEZE_SUPPORT == _ON)
            ScalerTimerWaitForActiveTimerEvent(_USER_TIMER_EVENT_OSD_DISABLE_FREEZE_MSG);
#endif

#if(_VGA_SUPPORT == _ON)
            if(SysSourceGetSourceType() == _SOURCE_VGA)
            {
                if(UserInterfaceGetFirstAutoConfigStatus() == _TRUE)
                {
                    OsdDispAutoConfigProc();
                }
            }
#endif

            if(GET_OSD_STATE() == _MENU_NONE)
            {
                OsdDispOsdMessage(_OSD_DISP_INPUT_SIGNAL_MSG);
                ScalerTimerActiveTimerEvent(SEC(3), _USER_TIMER_EVENT_OSD_DISABLE);
            }
            break;

        case _OSDEVENT_SAVE_NVRAM_SYSTEMDATA_MSG:
            UserCommonNVRamSaveSystemData();
            break;

#if(_VGA_SUPPORT == _ON)
        case _OSDEVENT_SAVE_NVRAM_MODEUSERDATA_MSG:
            UserCommonNVRamSaveModeUserData();
            break;
#endif
        case _OSDEVENT_SAVE_NVRAM_OSDUSERDATA_MSG:
            RTDNVRamSaveOSDData();

#if(_TWO_CHIP_DATA_COMMUNICATION_SUPPORT == _ON)
            UserCommonDataExchangeSetSentDataEvent(_OSDEVENT_SAVE_NVRAM_OSDUSERDATA_MSG);
#endif
            break;

		case _OSDEVENT_SAVE_NVRAM_MEDICAL_BACKLIGHT_MSG:
		    RTDNVRamSaveMedicalBacklightData();
		    break;

#if(_VGA_SUPPORT == _ON)
        case _OSDEVENT_SAVE_NVRAM_ADCDATA_MSG:
            if(ScalerColorGetColorSpaceRGB(UserCommonInterfaceGetColorFormat()) == _TRUE)
            {
                UserCommonNVRamSaveADCSetting(_COLOR_SPACE_RGB);
            }
            else
            {
                UserCommonNVRamSaveADCSetting(_COLOR_SPACE_YPBPR);
            }
            break;
#endif

        case _OSDEVENT_SAVE_NVRAM_COLORPROC_MSG:
            RTDNVRamSaveColorSetting(GET_COLOR_TEMP_TYPE());

#if(_TWO_CHIP_DATA_COMMUNICATION_SUPPORT == _ON)
            UserCommonDataExchangeSetSentDataEvent(_OSDEVENT_SAVE_NVRAM_COLORPROC_MSG);
#endif
            break;

        case _OSDEVENT_SAVE_NVRAM_BRICON_MSG:
            RTDNVRamSaveBriCon(SysSourceGetSourceType());

#if(_TWO_CHIP_DATA_COMMUNICATION_SUPPORT == _ON)
            UserCommonDataExchangeSetSentDataEvent(_OSDEVENT_SAVE_NVRAM_BRICON_MSG);
#endif
            break;

        case _OSDEVENT_SAVE_NVRAM_OSDSIXCOLORDATA_MSG:
            RTDNVRamSaveSixColorData();
            break;

#if(_DP_SUPPORT == _ON)
        /*case _OSDEVENT_DP_VERSIOM_MSG:
            SET_OSD_STATE(_MENU_HOTKEY_DP_OPTION);

            if(SysSourceGetSourceType() == _SOURCE_DP)
            {
                if(SysSourceGetInputPort() == _D0_INPUT_PORT)
                {
                    OsdDispHotKeyOptionMenu(_HOTKEY_DP_D0_OPTION);
                }
                else if(SysSourceGetInputPort() == _D1_INPUT_PORT)
                {
                    OsdDispHotKeyOptionMenu(_HOTKEY_DP_D1_OPTION);
                }
                else if(SysSourceGetInputPort() == _D2_INPUT_PORT)
                {
                    OsdDispHotKeyOptionMenu(_HOTKEY_DP_D2_OPTION);
                }
                else if(SysSourceGetInputPort() == _D6_INPUT_PORT)
                {
                    OsdDispHotKeyOptionMenu(_HOTKEY_DP_D6_OPTION);
                }
            }
            else
            {
#if (_D0_INPUT_PORT_TYPE == _D0_DP_PORT)
                OsdDispHotKeyOptionMenu(_HOTKEY_DP_D0_OPTION);
#elif (_D1_INPUT_PORT_TYPE == _D1_DP_PORT)
                OsdDispHotKeyOptionMenu(_HOTKEY_DP_D1_OPTION);
#elif (_D2_INPUT_PORT_TYPE == _D2_DP_PORT)
                OsdDispHotKeyOptionMenu(_HOTKEY_DP_D2_OPTION);
#elif (_D6_INPUT_PORT_TYPE == _D6_DP_PORT)
                OsdDispHotKeyOptionMenu(_HOTKEY_DP_D6_OPTION);
#else
                SET_OSD_STATE(_MENU_NONE);
#endif
            }

            UserCommonInterfacePanelPowerAction(_BACKLIGHT_ON);
            break;*/
#endif
        case _OSDEVENT_SHOW_FACTORY_MODE_MSG:
            RTDFactoryMainMenu();
            break;

		case _OSDEVENT_LIGHTBOX_MODE_MSG:            
		    if((SysModeGetModeState() == _MODE_STATUS_NOSIGNAL)||(SysModeGetModeState() == _MODE_STATUS_ACTIVE))
            {
	            ScalerTimerCancelTimerEvent(_USER_TIMER_EVENT_GO_TO_POWER_SAVING);
	            ScalerTimerCancelTimerEvent(_USER_TIMER_EVENT_OSD_SHOW_NO_CABLE);
	            ScalerTimerCancelTimerEvent(_USER_TIMER_EVENT_OSD_SHOW_NO_SIGNAL);

	            SET_OSD_STATE(_MENU_HOTKEY_LIGHTBOX);
	            OsdDispHotKeyOptionMenu(_HOTKEY_LIGHTBOX);
	            if(GET_OSD_LIGHTBOXMODE_STATUS() == _OFF)
	            {
	                ScalerTimerActiveTimerEvent(SEC(4), _USER_TIMER_EVENT_OSD_DISABLE);
	            }
	            else
	            {
	                ScalerTimerCancelTimerEvent(_USER_TIMER_EVENT_OSD_DISABLE);
	            }
	            UserCommonInterfacePanelPowerAction(_BACKLIGHT_ON);
            }
			break;
			
		case _OSDEVENT_SHOW_FREEZE_MODE_MSG:		
	        SET_OSD_STATE(_MENU_HOTKEY_FREEZE);
	        OsdDispHotKeyOptionMenu(_HOTKEY_FREEZE);
			break;
			
        default:
            break;
    }

    SET_OSD_EVENT_MESSAGE(_OSDEVENT_NONE_MSG);
}
void KECHotKeyStatusProcess(void)
{
    if((GET_KEYMESSAGE() == _MUTE_KEY_MESSAGE) && (GET_OSD_STATE() != _MENU_HOTKEY_MUTE))
    {
        OsdDispDisableOsd();
    }

    if((GET_KEYMESSAGE() == _SOURCE_KEY_MESSAGE) && (GET_OSD_STATE() != _MENU_HOTKEY_SOURCE))
    {
        OsdDispDisableOsd();
    }
    if(((GET_KEYMESSAGE() == _BRIGHTNESS_DEC_KEY_MESSAGE) || 
        (GET_KEYMESSAGE() == _BRIGHTNESS_INC_KEY_MESSAGE)) && (GET_OSD_STATE() != _MENU_HOTKEY_BRIGHTNESS))
    {
        OsdDispDisableOsd();
    }
    if(((GET_KEYMESSAGE() == _CONTRAST_DEC_KEY_MESSAGE) || 
        (GET_KEYMESSAGE() == _CONTRAST_INC_KEY_MESSAGE)) && (GET_OSD_STATE() != _MENU_HOTKEY_CONTRAST))
    {
        OsdDispDisableOsd();
    }
    
    if(SysModeGetModeState() != _MODE_STATUS_NOSIGNAL)
    {
	    if(((GET_KEYMESSAGE() == _VOL_DEC_KEY_MESSAGE) || 
	        (GET_KEYMESSAGE() == _VOL_INC_KEY_MESSAGE)) && (GET_OSD_STATE() != _MENU_HOTKEY_VOLUME))
	    {
	        OsdDispDisableOsd();
	    }
    }
    if(((GET_KEYMESSAGE() == _BACKLIGHT_DEC_KEY_MESSAGE) || 
        (GET_KEYMESSAGE() == _BACKLIGHT_INC_KEY_MESSAGE)) && (GET_OSD_STATE() != _MENU_HOTKEY_BACKLIGHT))
    {
        OsdDispDisableOsd();
    }

}
void UserKeyConvert(void)
{
    #if(_MENU_KEY_FUNC == _MENU_KEY_FOR_ENTER)
	if((GET_KEYMESSAGE() == _MENU_KEY_MESSAGE) && (GET_OSD_STATE() >= _MAINMENU_START) && (GET_OSD_STATE() <= _MAINMENU_END))
	{
        SET_KEYMESSAGE(_ENTER_KEY_MESSAGE);
	}
    #endif

}
//--------------------------------------------------
// Description  : Menu None State,Key Process
// Input Value  : None
// Output Value : None
//--------------------------------------------------
void MenuNone(void)
{
    switch(GET_KEYMESSAGE())
    {
        case _MENU_KEY_MESSAGE:
            if(SysModeGetModeState() == _MODE_STATUS_POWER_SAVING)
            {
                SET_OSD_POWER_SAVING_KEY_WAKEUP(_TRUE);

                if((SysPowerGetPowerStatus() == _POWER_STATUS_SAVING) || (SysPowerGetPowerStatus() == _POWER_STATUS_NOSUPPORT_SAVING))
                {
                    SysPowerSetTargetPowerStatus(_POWER_STATUS_NORMAL);
                }
            }
            else if(SysModeGetModeState() == _MODE_STATUS_ACTIVE)
            {
                OsdFuncSetOsdItemFlag();
                OsdDispMainMenu();
            }
            break;

        case _SOURCE_KEY_MESSAGE:
        //case _RIGHT_KEY_MESSAGE:
		#if(_KEYBOARD_TYPE != _KB_TOPTECH)        
            // input source
            CLR_KEYREPEATENABLE();

            if(SysModeGetModeState() == _MODE_STATUS_POWER_SAVING)
            {
                SET_OSD_POWER_SAVING_SHOW_SOURCE(_TRUE);

                if((SysPowerGetPowerStatus() == _POWER_STATUS_SAVING) || (SysPowerGetPowerStatus() == _POWER_STATUS_NOSUPPORT_SAVING))
                {
                    SysPowerSetTargetPowerStatus(_POWER_STATUS_NORMAL);
                }
            }
            else if((SysModeGetModeState() == _MODE_STATUS_NOSUPPORT) || (SysModeGetModeState() == _MODE_STATUS_NOSIGNAL))
            {
                SET_OSD_EVENT_MESSAGE(_OSDEVENT_SHOW_CHANGE_SOURCE_MENU_MSG);
            }
            else if(SysModeGetModeState() == _MODE_STATUS_ACTIVE)
            {
                SET_OSD_STATE(_MENU_HOTKEY_SOURCE);
                OsdFuncSetOsdItemFlag();
                g_usBackupValue = GET_OSD_INPUT_PORT_OSD_ITEM();
                OsdDispHotKeySourceMenu();
            }
		#endif
            break;

		case _RIGHT_KEY_MESSAGE:
            if(SysModeGetModeState() == _MODE_STATUS_POWER_SAVING)
            {
                SET_OSD_POWER_SAVING_KEY_WAKEUP(_TRUE);

                if((SysPowerGetPowerStatus() == _POWER_STATUS_SAVING) || (SysPowerGetPowerStatus() == _POWER_STATUS_NOSUPPORT_SAVING))
                {
                    SysPowerSetTargetPowerStatus(_POWER_STATUS_NORMAL);
                }
                
            }else if(SysModeGetModeState() == _MODE_STATUS_ACTIVE)
            {
                // active show input information
                //OsdDispOsdMessage(_OSD_DISP_INPUT_SIGNAL_MSG);
                //ScalerTimerActiveTimerEvent(SEC(5), _USER_TIMER_EVENT_OSD_DISABLE);
                SET_OSD_STATE(_MENU_HOTKEY_BACKLIGHT);
                OsdDispHotKeyOptionMenu(_HOTKEY_BACKLIGHT);
            }

			break;
			
		case _BACKLIGHT_DEC_KEY_MESSAGE:
		case _BACKLIGHT_INC_KEY_MESSAGE:
        case _LEFT_KEY_MESSAGE:
            if(SysModeGetModeState() == _MODE_STATUS_POWER_SAVING)
            {
                SET_OSD_POWER_SAVING_KEY_WAKEUP(_TRUE);

                if((SysPowerGetPowerStatus() == _POWER_STATUS_SAVING) || (SysPowerGetPowerStatus() == _POWER_STATUS_NOSUPPORT_SAVING))
                {
                    SysPowerSetTargetPowerStatus(_POWER_STATUS_NORMAL);
                }
                
            }else if(SysModeGetModeState() == _MODE_STATUS_ACTIVE)
            {
                // active show input information
                //OsdDispOsdMessage(_OSD_DISP_INPUT_SIGNAL_MSG);
                //ScalerTimerActiveTimerEvent(SEC(5), _USER_TIMER_EVENT_OSD_DISABLE);
				#if(_KEYBOARD_TYPE == _KB_QN_TYPEC)
                SET_OSD_STATE(_MENU_HOTKEY_VOLUME);
                OsdDispHotKeyOptionMenu(_HOTKEY_VOLUME);
                #else
                SET_OSD_STATE(_MENU_HOTKEY_BACKLIGHT);
                OsdDispHotKeyOptionMenu(_HOTKEY_BACKLIGHT);
                #endif
            }
			/*#if(_DP_DEBUG_MSG == _ON)
            else if(SysModeGetModeState() == _MODE_STATUS_POWER_SAVING)
            {
                SET_OSD_POWER_SAVING_SHOW_DP_INFO(_TRUE);

                if((SysPowerGetPowerStatus() == _POWER_STATUS_SAVING) || (SysPowerGetPowerStatus() == _POWER_STATUS_NOSUPPORT_SAVING))
                {
                    SysPowerSetTargetPowerStatus(_POWER_STATUS_NORMAL);
                }
            }
            else
            {
                OsdDispOsdMessage(_OSD_DISP_INPUT_SIGNAL_MSG);
                ScalerTimerCancelTimerEvent(_USER_TIMER_EVENT_OSD_DISABLE);
                ScalerTimerCancelTimerEvent(_USER_TIMER_EVENT_OSD_SHOW_NO_CABLE);
                ScalerTimerCancelTimerEvent(_USER_TIMER_EVENT_OSD_SHOW_NO_SIGNAL);
                ScalerTimerCancelTimerEvent(_USER_TIMER_EVENT_OSD_SHOW_POWER_SAVING);
                ScalerTimerCancelTimerEvent(_USER_TIMER_EVENT_GO_TO_POWER_SAVING);
            }
			#endif*/
            break;

        case _EXIT_KEY_MESSAGE:
	        if(SysModeGetModeState() == _MODE_STATUS_POWER_SAVING)
	        {
	            SET_OSD_POWER_SAVING_KEY_WAKEUP(_TRUE);
	        
	            if((SysPowerGetPowerStatus() == _POWER_STATUS_SAVING) || (SysPowerGetPowerStatus() == _POWER_STATUS_NOSUPPORT_SAVING))
	            {
	                SysPowerSetTargetPowerStatus(_POWER_STATUS_NORMAL);
	            }
	        }
			else if(SysModeGetModeState() == _MODE_STATUS_ACTIVE)
            {
                SET_OSD_STATE(_MENU_HOTKEY_GAMMA);
                OsdDispHotKeyOptionMenu(_HOTKEY_GAMMA);
            }
            break;

#if(_KEYBOARD_TYPE != _KB_TOPTECH)
        case _AUTO_KEY_MESSAGE:
            // auto adjust            
            if(SysModeGetModeState() == _MODE_STATUS_POWER_SAVING)
            {
                SET_OSD_POWER_SAVING_KEY_WAKEUP(_TRUE);

                if((SysPowerGetPowerStatus() == _POWER_STATUS_SAVING) || (SysPowerGetPowerStatus() == _POWER_STATUS_NOSUPPORT_SAVING))
                {
                    SysPowerSetTargetPowerStatus(_POWER_STATUS_NORMAL);
                }
                
            }
		#if(_VGA_SUPPORT == _ON)
            else if((SysModeGetModeState() == _MODE_STATUS_ACTIVE) && (GET_FAIL_SAFE_MODE() == _FALSE) && (SysSourceGetSourceType() == _SOURCE_VGA))
            {
				#if(_FREEZE_SUPPORT == _ON)
                if(GET_OSD_FREEZE_STATUS() == _ON)
                {
                    SET_OSD_FREEZE_STATUS(_OFF);
                    UserCommonAdjustDisplayFreeze(GET_OSD_FREEZE_STATUS());
                    OsdDispOsdMessage(_OSD_DISP_DISABLE_FREEZE_MSG);
                    ScalerTimerActiveTimerEvent(SEC(1), _USER_TIMER_EVENT_OSD_DISABLE_FREEZE_MSG);
                }
				#endif

                SET_OSD_EVENT_MESSAGE(_OSDEVENT_DO_AUTO_CONFIG_MSG);
            }
		#endif
		
			#if 0
	        // ddcci
	        if(SysModeGetModeState() == _MODE_STATUS_POWER_SAVING)
	        {
	            SET_OSD_WAKE_UP_SWITCH_DDCCI_PORT(_TRUE);

	            if((SysPowerGetPowerStatus() == _POWER_STATUS_SAVING) || (SysPowerGetPowerStatus() == _POWER_STATUS_NOSUPPORT_SAVING))
	            {
	                SysPowerSetTargetPowerStatus(_POWER_STATUS_NORMAL);
	            }
	        }
	        else if((SysModeGetModeState() == _MODE_STATUS_NOSUPPORT) || (SysModeGetModeState() == _MODE_STATUS_NOSIGNAL))
	        {
	            //SET_OSD_EVENT_MESSAGE(_OSDEVENT_WAKE_UP_SWITCH_DDCCI_PORT_MSG);
	        }
			#endif
            break;
#endif

#if(_KEYBOARD_TYPE == _KB_TOPTECH)
        case _AUTO_KEY_MESSAGE:
            // input source
            CLR_KEYREPEATENABLE();

            if(SysModeGetModeState() == _MODE_STATUS_POWER_SAVING)
            {
                SET_OSD_POWER_SAVING_SHOW_SOURCE(_TRUE);

                if((SysPowerGetPowerStatus() == _POWER_STATUS_SAVING) || (SysPowerGetPowerStatus() == _POWER_STATUS_NOSUPPORT_SAVING))
                {
                    SysPowerSetTargetPowerStatus(_POWER_STATUS_NORMAL);
                }
            }
            else if((SysModeGetModeState() == _MODE_STATUS_NOSUPPORT) || (SysModeGetModeState() == _MODE_STATUS_NOSIGNAL))
            {
                SET_OSD_EVENT_MESSAGE(_OSDEVENT_SHOW_CHANGE_SOURCE_MENU_MSG);
            }
            else if(SysModeGetModeState() == _MODE_STATUS_ACTIVE)
            {
                SET_OSD_STATE(_MENU_HOTKEY_SOURCE);
                OsdFuncSetOsdItemFlag();
                g_usBackupValue = GET_OSD_INPUT_PORT_OSD_ITEM();
                OsdDispHotKeySourceMenu();
            }
            break;            
#endif
		
		case _VOL_DEC_KEY_MESSAGE:
        case _VOL_INC_KEY_MESSAGE:            
        	if(SysModeGetModeState() == _MODE_STATUS_POWER_SAVING)
            {
                SET_OSD_POWER_SAVING_KEY_WAKEUP(_TRUE);

                if((SysPowerGetPowerStatus() == _POWER_STATUS_SAVING) || (SysPowerGetPowerStatus() == _POWER_STATUS_NOSUPPORT_SAVING))
                {
                    SysPowerSetTargetPowerStatus(_POWER_STATUS_NORMAL);
                }
                
            }else if(SysModeGetModeState() == _MODE_STATUS_ACTIVE)
            {
                SET_OSD_STATE(_MENU_HOTKEY_VOLUME);
                OsdDispHotKeyOptionMenu(_HOTKEY_VOLUME);
            }
            /*else if((SysModeGetModeState() == _MODE_STATUS_NOSUPPORT) || (SysModeGetModeState() == _MODE_STATUS_NOSIGNAL))
            {
                ScalerTimerActiveTimerEvent(SEC(2), _USER_TIMER_EVENT_OSD_SHOW_NO_SIGNAL);

            }*/
			break;
			
        case _BRIGHTNESS_DEC_KEY_MESSAGE:
        case _BRIGHTNESS_INC_KEY_MESSAGE:            
        	if(SysModeGetModeState() == _MODE_STATUS_POWER_SAVING)
            {
                SET_OSD_POWER_SAVING_KEY_WAKEUP(_TRUE);

                if((SysPowerGetPowerStatus() == _POWER_STATUS_SAVING) || (SysPowerGetPowerStatus() == _POWER_STATUS_NOSUPPORT_SAVING))
                {
                    SysPowerSetTargetPowerStatus(_POWER_STATUS_NORMAL);
                }
                
            }else if(SysModeGetModeState() == _MODE_STATUS_ACTIVE)
            {
                SET_OSD_STATE(_MENU_HOTKEY_BRIGHTNESS);
                OsdDispHotKeyOptionMenu(_HOTKEY_BRIGHTNESS);
            }
            break;
            
        case _CONTRAST_DEC_KEY_MESSAGE:
        case _CONTRAST_INC_KEY_MESSAGE:            
        	if(SysModeGetModeState() == _MODE_STATUS_POWER_SAVING)
            {
                SET_OSD_POWER_SAVING_KEY_WAKEUP(_TRUE);

                if((SysPowerGetPowerStatus() == _POWER_STATUS_SAVING) || (SysPowerGetPowerStatus() == _POWER_STATUS_NOSUPPORT_SAVING))
                {
                    SysPowerSetTargetPowerStatus(_POWER_STATUS_NORMAL);
                }
                
            }else if(SysModeGetModeState() == _MODE_STATUS_ACTIVE)
            {
                SET_OSD_STATE(_MENU_HOTKEY_CONTRAST);
                OsdDispHotKeyOptionMenu(_HOTKEY_CONTRAST);
            }
            break;

        case _MUTE_KEY_MESSAGE:            
        	if(SysModeGetModeState() == _MODE_STATUS_POWER_SAVING)
            {
                SET_OSD_POWER_SAVING_KEY_WAKEUP(_TRUE);

                if((SysPowerGetPowerStatus() == _POWER_STATUS_SAVING) || (SysPowerGetPowerStatus() == _POWER_STATUS_NOSUPPORT_SAVING))
                {
                    SysPowerSetTargetPowerStatus(_POWER_STATUS_NORMAL);
                }
                
            }else if(SysModeGetModeState() == _MODE_STATUS_ACTIVE)
            {
                SET_OSD_STATE(_MENU_HOTKEY_MUTE);
                OsdDispHotKeyOptionMenu(_HOTKEY_MUTE);
            }
        	break;
        	
        default:
            if(SysModeGetModeState() == _MODE_STATUS_POWER_SAVING)
            {
                SET_OSD_POWER_SAVING_KEY_WAKEUP(_TRUE);

                if((SysPowerGetPowerStatus() == _POWER_STATUS_SAVING) || (SysPowerGetPowerStatus() == _POWER_STATUS_NOSUPPORT_SAVING))
                {
                    SysPowerSetTargetPowerStatus(_POWER_STATUS_NORMAL);
                }
            }
            break;
    }
}
//--------------------------------------------------
// Description  : Color Page Process
// Input Value  : None
// Output Value : None
//--------------------------------------------------
void MenuMainColor(void)
{
    switch(GET_KEYMESSAGE())
    {
    	case _ENTER_KEY_MESSAGE:
        case _RIGHT_KEY_MESSAGE:
	        ucStartItem = OsdFuncGetStartEndItem(_COLOR_PAGE_END,_COLOR_PAGE_START, _COLOR_PAGE_END,_INC,1);
	        ucEndItem 	= OsdFuncGetStartEndItem(ucStartItem,	 _COLOR_PAGE_START, _COLOR_PAGE_END,_INC,(((_COLOR_PAGE_END - ucStartItem) >= _OSD_ITEM_COUNT)?_OSD_ITEM_COUNT:(_COLOR_PAGE_END - ucStartItem)));
                
	        SET_OSD_STATE(OsdFuncGetVilidOsdState(_COLOR_PAGE_END,_COLOR_PAGE_START, _COLOR_PAGE_END, 1, _ON));
        
	        OsdDispUpdateSubMenuStatus(GET_OSD_STATE(), _ST_SELECT);
            break;

        case _MENU_KEY_MESSAGE:
        case _UP_KEY_MESSAGE:
        case _DOWN_KEY_MESSAGE:
            OsdDispNextMainItemProcess();
            break;

        case _EXIT_KEY_MESSAGE:
            OsdDispDisableOsd();
			#if(_USE_BATTERY)
            bDrawBattery = _TRUE;
			#endif
            break;

        default:
            break;
    }
}
//--------------------------------------------------
// Description  : Function Page Process
// Input Value  : None
// Output Value : None
//--------------------------------------------------
void MenuMainFunction(void)
{
    switch(GET_KEYMESSAGE())
    {
        case _MENU_KEY_MESSAGE:
        case _UP_KEY_MESSAGE:
        case _DOWN_KEY_MESSAGE:
            OsdDispNextMainItemProcess();
            break;
            
        case _ENTER_KEY_MESSAGE:
        case _RIGHT_KEY_MESSAGE:
	        ucStartItem = OsdFuncGetStartEndItem(_FUNCTION_PAGE_END,_FUNCTION_PAGE_START, _FUNCTION_PAGE_END,_INC,1);
	        ucEndItem 	= OsdFuncGetStartEndItem(ucStartItem,	 _FUNCTION_PAGE_START, _FUNCTION_PAGE_END,_INC,(((_FUNCTION_PAGE_END - ucStartItem) >= _OSD_ITEM_COUNT)?_OSD_ITEM_COUNT:(_FUNCTION_PAGE_END - ucStartItem)));
                
	        SET_OSD_STATE(OsdFuncGetVilidOsdState(_FUNCTION_PAGE_END,_FUNCTION_PAGE_START, _FUNCTION_PAGE_END, 1, _ON));
        
	        OsdDispUpdateSubMenuStatus(GET_OSD_STATE(), _ST_SELECT);
            break;

        case _EXIT_KEY_MESSAGE:
            OsdDispDisableOsd();
			#if(_USE_BATTERY)
            bDrawBattery = _TRUE;
			#endif
            break;

        default:
            break;
    }
}
//--------------------------------------------------
// Description  : OSD Page Process
// Input Value  : None
// Output Value : None
//--------------------------------------------------
void MenuMainOSD(void)
{
    switch(GET_KEYMESSAGE())
    {
        case _MENU_KEY_MESSAGE:
        case _UP_KEY_MESSAGE:
        case _DOWN_KEY_MESSAGE:
            OsdDispNextMainItemProcess();
            break;

        case _ENTER_KEY_MESSAGE:
        case _RIGHT_KEY_MESSAGE:
	        ucStartItem = OsdFuncGetStartEndItem(_OSD_PAGE_END,_OSD_PAGE_START, _OSD_PAGE_END,_INC,1);
	        ucEndItem 	= OsdFuncGetStartEndItem(ucStartItem,	 _OSD_PAGE_START, _OSD_PAGE_END,_INC,(((_OSD_PAGE_END - ucStartItem) >= _OSD_ITEM_COUNT)?_OSD_ITEM_COUNT:(_OSD_PAGE_END - ucStartItem)));
                
	        SET_OSD_STATE(OsdFuncGetVilidOsdState(_OSD_PAGE_END,_OSD_PAGE_START, _OSD_PAGE_END, 1, _ON));
        
	        OsdDispUpdateSubMenuStatus(GET_OSD_STATE(), _ST_SELECT);
            break;

        case _EXIT_KEY_MESSAGE:
            OsdDispDisableOsd();
			#if(_USE_BATTERY)
            bDrawBattery = _TRUE;
			#endif
            break;

        default:
            break;
    }
}
//--------------------------------------------------
// Description  : Audio Page Process
// Input Value  : None
// Output Value : None
//--------------------------------------------------
void MenuMainAudio(void)
{
    switch(GET_KEYMESSAGE())
    {
        case _MENU_KEY_MESSAGE:
        case _UP_KEY_MESSAGE:
        case _DOWN_KEY_MESSAGE:
            OsdDispNextMainItemProcess();
            break;

        case _ENTER_KEY_MESSAGE:
        case _RIGHT_KEY_MESSAGE:
	        ucStartItem = OsdFuncGetStartEndItem(_AUDIO_PAGE_END,_AUDIO_PAGE_START, _AUDIO_PAGE_END,_INC,1);
	        ucEndItem 	= OsdFuncGetStartEndItem(ucStartItem,	 _AUDIO_PAGE_START, _AUDIO_PAGE_END,_INC,(((_AUDIO_PAGE_END - ucStartItem) >= _OSD_ITEM_COUNT)?_OSD_ITEM_COUNT:(_AUDIO_PAGE_END - ucStartItem)));
                
	        SET_OSD_STATE(OsdFuncGetVilidOsdState(_AUDIO_PAGE_END,_AUDIO_PAGE_START, _AUDIO_PAGE_END, 1, _ON));
        
	        OsdDispUpdateSubMenuStatus(GET_OSD_STATE(), _ST_SELECT);
            break;

        case _EXIT_KEY_MESSAGE:
            OsdDispDisableOsd();
			#if(_USE_BATTERY)
            bDrawBattery = _TRUE;
			#endif
            break;

        default:
            break;
    }
}
//--------------------------------------------------
// Description  : Service Level2 Page Process
// Input Value  : None
// Output Value : None
//--------------------------------------------------
void MenuMainServiceLevel2(void)
{
	static BYTE ucPswCount = 0;

	if(GET_KEYMESSAGE() == tServiceLevel2Password[ucPswCount])
	{
		ucPswCount ++;
		if(ucPswCount >= _PSW_CNT)
		{
            ucEnterServiceLevel_flag = _TRUE;
            ucPswCount = 0;
            
			SET_OSD_STATE(_SERVICELEVEL2_PAGE_START);
			DrawServiceLevel2MainItem(GET_OSD_STATE());
			
            OsdFuncCalcSubMenuStartEndItem(GET_OSD_STATE());
	        DrawSubMenu(GET_OSD_STATE());
			return;
		}
		else
			return;
	}
	else
	{
		ucPswCount = 0;
	}

    switch(GET_KEYMESSAGE())
    {
        case _MENU_KEY_MESSAGE:
        case _UP_KEY_MESSAGE:
        case _DOWN_KEY_MESSAGE:
            OsdDispNextMainItemProcess();
            ucEnterServiceLevel_flag = _FALSE;
            break;

        case _ENTER_KEY_MESSAGE:
        case _RIGHT_KEY_MESSAGE:
        case _LEFT_KEY_MESSAGE:
            break;

        case _EXIT_KEY_MESSAGE:
            OsdDispDisableOsd();
			#if(_USE_BATTERY)
            bDrawBattery = _TRUE;
			#endif
            break;

        default:
            break;
    }
}
//--------------------------------------------------
// Description  : Analog Page Process
// Input Value  : None
// Output Value : None
//--------------------------------------------------
void MenuMainAnalog(void)
{
    switch(GET_KEYMESSAGE())
    {
        case _MENU_KEY_MESSAGE:
        case _UP_KEY_MESSAGE:
        case _DOWN_KEY_MESSAGE:
            OsdDispNextMainItemProcess();
            break;

        case _ENTER_KEY_MESSAGE:
        case _RIGHT_KEY_MESSAGE:
	        ucStartItem = OsdFuncGetStartEndItem(_ANALOG_PAGE_END,_ANALOG_PAGE_START, _ANALOG_PAGE_END,_INC,1);
	        ucEndItem 	= OsdFuncGetStartEndItem(ucStartItem,	 _ANALOG_PAGE_START, _ANALOG_PAGE_END,_INC,(((_ANALOG_PAGE_END - ucStartItem) >= _OSD_ITEM_COUNT)?_OSD_ITEM_COUNT:(_ANALOG_PAGE_END - ucStartItem)));
                
	        SET_OSD_STATE(OsdFuncGetVilidOsdState(_ANALOG_PAGE_END,_ANALOG_PAGE_START, _ANALOG_PAGE_END, 1, _ON));
        
	        OsdDispUpdateSubMenuStatus(GET_OSD_STATE(), _ST_SELECT);
            break;

        case _EXIT_KEY_MESSAGE:
            OsdDispDisableOsd();
			#if(_USE_BATTERY)
            bDrawBattery = _TRUE;
			#endif
            break;

        default:
            break;
    }
}

//==============================================================================
//Color Sub Page
//==============================================================================
//--------------------------------------------------
// Description  : Brightness Process
// Input Value  : None
// Output Value : None
//--------------------------------------------------
void MColorPageBrightnessProc(void)
{
    switch(GET_KEYMESSAGE())
    {
        case _MENU_KEY_MESSAGE:
        case _UP_KEY_MESSAGE:
        case _DOWN_KEY_MESSAGE:
        	OsdDispNextSubItemProcess(_COLOR_PAGE_START,_COLOR_PAGE_END);
            break;
			
		case _LEFT_KEY_MESSAGE:
		case _RIGHT_KEY_MESSAGE:
	        OsdItemValueUpdate(_COLOR_PAGE_BRIGHTNESS, GET_OSD_BRIGHTNESS(),ucCurrRow,_ITEM_ADJUST_COLOR);
		#if(_BRIGHTNESS_SUPPORT == _ON)
            UserAdjustBrightness(GET_OSD_BRIGHTNESS());
		#endif
			
            ScalerTimerReactiveTimerEvent(SEC(_OSD_DATA_SAVE_TIME), _USER_TIMER_EVENT_SAVE_BRICON_DATA_MSG);
			break;
			
        case _EXIT_KEY_MESSAGE:
	        OsdDispUpdateSubMenuStatus(GET_OSD_STATE(), _ST_NORMAL);
            OsdFuncCloseWindow(_OSD_SUB_SELECT_WIN);
	        SET_OSD_STATE(_MAIN_COLOR);
            break;

        default:
            break;
    }
}
//--------------------------------------------------
// Description  : Contrast Process
// Input Value  : None
// Output Value : None
//--------------------------------------------------
void MColorPageContrastProc(void)
{
    switch(GET_KEYMESSAGE())
    {
        case _MENU_KEY_MESSAGE:
        case _UP_KEY_MESSAGE:
        case _DOWN_KEY_MESSAGE:
        	OsdDispNextSubItemProcess(_COLOR_PAGE_START,_COLOR_PAGE_END);
            break;

        case _RIGHT_KEY_MESSAGE:
        case _LEFT_KEY_MESSAGE:
	        OsdItemValueUpdate(_COLOR_PAGE_CONTRAST, GET_OSD_CONTRAST(),ucCurrRow,_ITEM_ADJUST_COLOR);
			#if(_CONTRAST_SUPPORT == _ON)
            UserAdjustContrast(GET_OSD_CONTRAST());
			#endif
            ScalerTimerReactiveTimerEvent(SEC(_OSD_DATA_SAVE_TIME), _USER_TIMER_EVENT_SAVE_BRICON_DATA_MSG);
            break;

        case _EXIT_KEY_MESSAGE:
	        OsdDispUpdateSubMenuStatus(GET_OSD_STATE(), _ST_NORMAL);
            OsdFuncCloseWindow(_OSD_SUB_SELECT_WIN);
	        SET_OSD_STATE(_MAIN_COLOR);
            break;

        default:
            break;
    }
}
//--------------------------------------------------
// Description  : Backlight Process
// Input Value  : None
// Output Value : None
//--------------------------------------------------
void MColorPageBacklightProc(void)
{
    switch(GET_KEYMESSAGE())
    {
        case _MENU_KEY_MESSAGE:
        case _UP_KEY_MESSAGE:
        case _DOWN_KEY_MESSAGE:
        	OsdDispNextSubItemProcess(_COLOR_PAGE_START,_COLOR_PAGE_END);
            break;

        case _RIGHT_KEY_MESSAGE:
        case _LEFT_KEY_MESSAGE:
	        OsdItemValueUpdate(_COLOR_PAGE_BACKLIGHT, GET_OSD_BACKLIGHT(),ucCurrRow,_ITEM_ADJUST_COLOR);
            UserAdjustBacklightProcess();
            ScalerTimerReactiveTimerEvent(SEC(_OSD_DATA_SAVE_TIME), _USER_TIMER_EVENT_SAVE_USER_DATA_MSG);
            break;

        case _EXIT_KEY_MESSAGE:
	        OsdDispUpdateSubMenuStatus(GET_OSD_STATE(), _ST_NORMAL);
            OsdFuncCloseWindow(_OSD_SUB_SELECT_WIN);
	        SET_OSD_STATE(_MAIN_COLOR);
            break;

        default:
            break;
    }
}
//--------------------------------------------------
// Description  : ColorTemp Process
// Input Value  : None
// Output Value : None
//--------------------------------------------------
void MColorPageColorTempProc(void)
{
    switch(GET_KEYMESSAGE())
    {
        case _MENU_KEY_MESSAGE:
        case _UP_KEY_MESSAGE:
        case _DOWN_KEY_MESSAGE:
        	OsdDispNextSubItemProcess(_COLOR_PAGE_START,_COLOR_PAGE_END);
            break;

        case _RIGHT_KEY_MESSAGE:
        case _ENTER_KEY_MESSAGE:
            OsdFuncCloseWindow(_OSD_SUB_SELECT_WIN);
            OsdFuncCalcSubMenuStartEndItem(GET_OSD_STATE());

	        SET_OSD_STATE(OsdFuncGetVilidOsdState(_COLORTEMP_SUBPAGE_END,_COLORTEMP_SUBPAGE_START, _COLORTEMP_SUBPAGE_END, 1, _ON));
			DrawColorTempSubPage();
			
	        OsdDispUpdateSubMenuStatus(GET_OSD_STATE(), _ST_SELECT);
            break;

        case _EXIT_KEY_MESSAGE:
	        OsdDispUpdateSubMenuStatus(GET_OSD_STATE(), _ST_NORMAL);
            OsdFuncCloseWindow(_OSD_SUB_SELECT_WIN);
	        SET_OSD_STATE(_MAIN_COLOR);
            break;

        default:
            break;
    }
}
//--------------------------------------------------
// Description  : ColorTemp Process
// Input Value  : None
// Output Value : None
//--------------------------------------------------
void MColorPageGammaProc(void)
{
    switch(GET_KEYMESSAGE())
    {
        case _MENU_KEY_MESSAGE:
        case _UP_KEY_MESSAGE:
        case _DOWN_KEY_MESSAGE:
        	OsdDispNextSubItemProcess(_COLOR_PAGE_START,_COLOR_PAGE_END);
            break;

        case _RIGHT_KEY_MESSAGE:
        case _LEFT_KEY_MESSAGE:
	        OsdItemValueUpdate(_COLOR_PAGE_GAMMA, GET_OSD_GAMMA(),ucCurrRow,_ITEM_ADJUST_COLOR);
			#if(_GAMMA_FUNCTION == _ON)
	            ScalerTimerWaitForEvent(_EVENT_DEN_STOP);
	            UserCommonAdjustGammaRegionEnable(_FUNCTION_OFF);

	            if(GET_OSD_GAMMA() != _GAMMA_OFF)
	            {
	                UserAdjustGamma(GET_OSD_GAMMA());
	                ScalerTimerWaitForEvent(_EVENT_DEN_STOP);
	                UserCommonAdjustGammaRegionEnable(_FUNCTION_ON);
	                
	            }
			#endif
            ScalerTimerReactiveTimerEvent(SEC(_OSD_DATA_SAVE_TIME), _USER_TIMER_EVENT_SAVE_USER_DATA_MSG);
            break;

        case _EXIT_KEY_MESSAGE:
	        OsdDispUpdateSubMenuStatus(GET_OSD_STATE(), _ST_NORMAL);
            OsdFuncCloseWindow(_OSD_SUB_SELECT_WIN);
	        SET_OSD_STATE(_MAIN_COLOR);
            break;

        default:
            break;
    }
}
//--------------------------------------------------
// Description  : ColorTemp Sub Page Process
// Input Value  : None
// Output Value : None
//--------------------------------------------------
void MColorTempSubPageColorTempProc(void)
{
    switch(GET_KEYMESSAGE())
    {
        case _MENU_KEY_MESSAGE:
        case _UP_KEY_MESSAGE:
        case _DOWN_KEY_MESSAGE:
        	OsdDispNextSubItemProcess(_COLORTEMP_SUBPAGE_START,_COLORTEMP_SUBPAGE_END);
            break;
            
        case _LEFT_KEY_MESSAGE:            
        case _RIGHT_KEY_MESSAGE:			
            OsdItemValueUpdate(_COLORTEMP_SUBPAGE_TYPE, GET_COLOR_TEMP_TYPE(),ucCurrRow,_ITEM_ADJUST_COLOR);
            RTDNVRamLoadColorSetting(GET_COLOR_TEMP_TYPE());
            DrawColorTempR(_ST_DISABLE);
            DrawColorTempG(_ST_DISABLE);
            DrawColorTempB(_ST_DISABLE);

            if(GET_COLOR_TEMP_TYPE() == _CT_USER)
			{
                OsdFuncOsdLine(ROW(_OSD_ITEM_SPACE*(_COLORTEMP_SUBPAGE_R - ucStartItem) + _OSD_ITEM_1_ROW_START - (_OSD_ITEM_SPACE - 1)),COL(_OSD_SUB_WIN_COL_START), WIDTH(_OSD_SUB_WIN_WIDTH), HEIGHT(_OSD_ITEM_SPACE*3), _SUB_NORMAL_COLOR, _OSD_BYTE2);
                //OsdFuncOsdLine(ROW(_OSD_ITEM_SPACE*(_COLORTEMP_SUBPAGE_R - ucStartItem) + _OSD_ITEM_1_ROW_START - (_OSD_ITEM_SPACE - 1)),COL(_OSD_SUB_WIN_COL_START), WIDTH(_OSD_SUB_WIN_WIDTH), HEIGHT(_OSD_ITEM_SPACE), COLOR(_CP_RED,_CP_BG), _OSD_BYTE2);
                //OsdFuncOsdLine(ROW(_OSD_ITEM_SPACE*(_COLORTEMP_SUBPAGE_G - ucStartItem) + _OSD_ITEM_1_ROW_START - (_OSD_ITEM_SPACE - 1)),COL(_OSD_SUB_WIN_COL_START), WIDTH(_OSD_SUB_WIN_WIDTH), HEIGHT(_OSD_ITEM_SPACE), COLOR(_CP_GREEN_1,_CP_BG), _OSD_BYTE2);
                //OsdFuncOsdLine(ROW(_OSD_ITEM_SPACE*(_COLORTEMP_SUBPAGE_B - ucStartItem) + _OSD_ITEM_1_ROW_START - (_OSD_ITEM_SPACE - 1)),COL(_OSD_SUB_WIN_COL_START), WIDTH(_OSD_SUB_WIN_WIDTH), HEIGHT(_OSD_ITEM_SPACE), COLOR(_CP_BLUE,_CP_BG), _OSD_BYTE2);
			}
			else
			{
                OsdFuncOsdLine(ROW(_OSD_ITEM_SPACE*(_COLORTEMP_SUBPAGE_R - ucStartItem) + _OSD_ITEM_1_ROW_START - (_OSD_ITEM_SPACE - 1)),COL(_OSD_SUB_WIN_COL_START), WIDTH(_OSD_SUB_WIN_WIDTH), HEIGHT(_OSD_ITEM_SPACE*3), _SUB_DISABLE_COLOR, _OSD_BYTE2);
                //OsdFuncOsdLine(ROW(_OSD_ITEM_SPACE*(_COLORTEMP_SUBPAGE_R - ucStartItem) + _OSD_ITEM_1_ROW_START - (_OSD_ITEM_SPACE - 1)),COL(_OSD_SUB_WIN_COL_START), WIDTH(_OSD_SUB_WIN_WIDTH), HEIGHT(_OSD_ITEM_SPACE), COLOR(_CP_GRAY_1,_CP_BG), _OSD_BYTE2);
                //OsdFuncOsdLine(ROW(_OSD_ITEM_SPACE*(_COLORTEMP_SUBPAGE_G - ucStartItem) + _OSD_ITEM_1_ROW_START - (_OSD_ITEM_SPACE - 1)),COL(_OSD_SUB_WIN_COL_START), WIDTH(_OSD_SUB_WIN_WIDTH), HEIGHT(_OSD_ITEM_SPACE), COLOR(_CP_GRAY_1,_CP_BG), _OSD_BYTE2);
                //OsdFuncOsdLine(ROW(_OSD_ITEM_SPACE*(_COLORTEMP_SUBPAGE_B - ucStartItem) + _OSD_ITEM_1_ROW_START - (_OSD_ITEM_SPACE - 1)),COL(_OSD_SUB_WIN_COL_START), WIDTH(_OSD_SUB_WIN_WIDTH), HEIGHT(_OSD_ITEM_SPACE), COLOR(_CP_GRAY_1,_CP_BG), _OSD_BYTE2);
			}
			
			#if(_CONTRAST_SUPPORT == _ON)
            UserAdjustContrast(GET_OSD_CONTRAST());
			#endif
            UserAdjustGammaUpdate();
            break;

        case _EXIT_KEY_MESSAGE:
            OsdFuncCloseWindow(_OSD_SUB_SELECT_WIN);
            OsdFuncCalcSubMenuStartEndItem(_MAIN_COLOR);
            
            SET_OSD_STATE(_COLOR_PAGE_COLORTEMP);
            DrawSubMenu(_MAIN_COLOR); 
	        
	        OsdDispUpdateSubMenuStatus(GET_OSD_STATE(), _ST_SELECT);
            break;

        default:
            break;
    }
}
//--------------------------------------------------
// Description  : ColorTemp Red Process
// Input Value  : None
// Output Value : None
//--------------------------------------------------
void MColorTempSubPageRedProc(void)
{
    switch(GET_KEYMESSAGE())
    {
        case _MENU_KEY_MESSAGE:
        case _UP_KEY_MESSAGE:
        case _DOWN_KEY_MESSAGE:
        	OsdDispNextSubItemProcess(_COLORTEMP_SUBPAGE_START,_COLORTEMP_SUBPAGE_END);
            break;
            
        case _LEFT_KEY_MESSAGE:            
        case _RIGHT_KEY_MESSAGE:			
            OsdItemValueUpdate(_COLORTEMP_SUBPAGE_R, GET_COLOR_TEMP_TYPE_USER_R(),ucCurrRow,_ITEM_ADJUST_COLOR);
            
			#if(_CONTRAST_SUPPORT == _ON)
            UserAdjustContrast(GET_OSD_CONTRAST());
			#endif
            UserAdjustGammaUpdate();
            ScalerTimerReactiveTimerEvent(SEC(_OSD_DATA_SAVE_TIME), _USER_TIMER_EVENT_SAVE_COLOR_PROC_DATA_MSG);
            break;

        case _EXIT_KEY_MESSAGE:
            OsdFuncCloseWindow(_OSD_SUB_SELECT_WIN);
            OsdFuncCalcSubMenuStartEndItem(_MAIN_COLOR);
            
            SET_OSD_STATE(_COLOR_PAGE_COLORTEMP);
            DrawSubMenu(_MAIN_COLOR); 
	        
	        OsdDispUpdateSubMenuStatus(GET_OSD_STATE(), _ST_SELECT);
            break;

        default:
            break;
    }
}
//--------------------------------------------------
// Description  : ColorTemp Green Process
// Input Value  : None
// Output Value : None
//--------------------------------------------------
void MColorTempSubPageGreenProc(void)
{
    switch(GET_KEYMESSAGE())
    {
        case _MENU_KEY_MESSAGE:
        case _UP_KEY_MESSAGE:
        case _DOWN_KEY_MESSAGE:
        	OsdDispNextSubItemProcess(_COLORTEMP_SUBPAGE_START,_COLORTEMP_SUBPAGE_END);
            break;
            
        case _LEFT_KEY_MESSAGE:            
        case _RIGHT_KEY_MESSAGE:			
            OsdItemValueUpdate(_COLORTEMP_SUBPAGE_G, GET_COLOR_TEMP_TYPE_USER_G(),ucCurrRow,_ITEM_ADJUST_COLOR);
            
			#if(_CONTRAST_SUPPORT == _ON)
            UserAdjustContrast(GET_OSD_CONTRAST());
			#endif
            UserAdjustGammaUpdate();
            ScalerTimerReactiveTimerEvent(SEC(_OSD_DATA_SAVE_TIME), _USER_TIMER_EVENT_SAVE_COLOR_PROC_DATA_MSG);
            break;

        case _EXIT_KEY_MESSAGE:
            OsdFuncCloseWindow(_OSD_SUB_SELECT_WIN);
            OsdFuncCalcSubMenuStartEndItem(_MAIN_COLOR);
            
            SET_OSD_STATE(_COLOR_PAGE_COLORTEMP);
            DrawSubMenu(_MAIN_COLOR); 
	        
	        OsdDispUpdateSubMenuStatus(GET_OSD_STATE(), _ST_SELECT);
            break;

        default:
            break;
    }
}
//--------------------------------------------------
// Description  : ColorTemp Blue Process
// Input Value  : None
// Output Value : None
//--------------------------------------------------
void MColorTempSubPageBlueProc(void)
{
    switch(GET_KEYMESSAGE())
    {
        case _MENU_KEY_MESSAGE:
        case _UP_KEY_MESSAGE:
        case _DOWN_KEY_MESSAGE:
        	OsdDispNextSubItemProcess(_COLORTEMP_SUBPAGE_START,_COLORTEMP_SUBPAGE_END);
            break;
            
        case _LEFT_KEY_MESSAGE:            
        case _RIGHT_KEY_MESSAGE:			
            OsdItemValueUpdate(_COLORTEMP_SUBPAGE_B, GET_COLOR_TEMP_TYPE_USER_B(),ucCurrRow,_ITEM_ADJUST_COLOR);
            
			#if(_CONTRAST_SUPPORT == _ON)
            UserAdjustContrast(GET_OSD_CONTRAST());
			#endif
            UserAdjustGammaUpdate();
            ScalerTimerReactiveTimerEvent(SEC(_OSD_DATA_SAVE_TIME), _USER_TIMER_EVENT_SAVE_COLOR_PROC_DATA_MSG);
            break;

        case _EXIT_KEY_MESSAGE:
            OsdFuncCloseWindow(_OSD_SUB_SELECT_WIN);
            OsdFuncCalcSubMenuStartEndItem(_MAIN_COLOR);
            
            SET_OSD_STATE(_COLOR_PAGE_COLORTEMP);
            DrawSubMenu(_MAIN_COLOR); 
	        
	        OsdDispUpdateSubMenuStatus(GET_OSD_STATE(), _ST_SELECT);
            break;

        default:
            break;
    }
}
//==============================================================================
//Function Page
//==============================================================================
//--------------------------------------------------
// Description  : AspectRatio Process
// Input Value  : None
// Output Value : None
//--------------------------------------------------
void MFunctionPageAspectRatioProc(void)
{
    switch(GET_KEYMESSAGE())
    {
        case _MENU_KEY_MESSAGE:
        case _UP_KEY_MESSAGE:
        case _DOWN_KEY_MESSAGE:
        	OsdDispNextSubItemProcess(_FUNCTION_PAGE_START,_FUNCTION_PAGE_END);
            break;
			
		case _LEFT_KEY_MESSAGE:
		case _RIGHT_KEY_MESSAGE:
	        OsdItemValueUpdate(_FUNCTION_PAGE_DISP_ASPECT, GET_OSD_ASPECT_RATIO_TYPE(),ucCurrRow,_ITEM_ADJUST_COLOR);
			#if(_ASPECT_RATIO_SUPPORT == _ON)
				#if(_ASPECT_RATIO_WITHOUT_MUTE == _ON)
                SysModeSetResetTarget(_MODE_ACTION_RESET_TO_DISPLAY_SETTING_WITHOUT_FORCETOBG);
				#else
                SysModeSetResetTarget(_MODE_ACTION_RESET_TO_DISPLAY_SETTING);
				#endif
			#endif
            ScalerTimerReactiveTimerEvent(SEC(_OSD_DATA_SAVE_TIME), _USER_TIMER_EVENT_SAVE_USER_DATA_MSG);
			break;
			
        case _EXIT_KEY_MESSAGE:
	        OsdDispUpdateSubMenuStatus(GET_OSD_STATE(), _ST_NORMAL);
            OsdFuncCloseWindow(_OSD_SUB_SELECT_WIN);
	        SET_OSD_STATE(_MAIN_FUNCTION);
            break;

        default:
            break;
    }
}
//--------------------------------------------------
// Description  : OverScan Process
// Input Value  : None
// Output Value : None
//--------------------------------------------------
void MFunctionPageOverScanProc(void)
{
    switch(GET_KEYMESSAGE())
    {
        case _MENU_KEY_MESSAGE:
        case _UP_KEY_MESSAGE:
        case _DOWN_KEY_MESSAGE:
        	OsdDispNextSubItemProcess(_FUNCTION_PAGE_START,_FUNCTION_PAGE_END);
            break;
			
		case _LEFT_KEY_MESSAGE:
		case _RIGHT_KEY_MESSAGE:
            if(SysModeGetModeState() == _MODE_STATUS_ACTIVE)
            {
                OsdItemValueUpdate(_FUNCTION_PAGE_OVER_SCAN, GET_OSD_OVERSCAN_STATUS(),ucCurrRow,_ITEM_ADJUST_COLOR);

				#if(_OVERSCAN_SUPPORT == _ON)
                SysModeSetResetTarget(_MODE_ACTION_RESET_TO_DISPLAY_SETTING);
				#endif
                ScalerTimerReactiveTimerEvent(SEC(_OSD_DATA_SAVE_TIME), _USER_TIMER_EVENT_SAVE_USER_DATA_MSG);
            }
			break;
			
        case _EXIT_KEY_MESSAGE:
	        OsdDispUpdateSubMenuStatus(GET_OSD_STATE(), _ST_NORMAL);
            OsdFuncCloseWindow(_OSD_SUB_SELECT_WIN);
	        SET_OSD_STATE(_MAIN_FUNCTION);
            break;

        default:
            break;
    }
}
//--------------------------------------------------
// Description  : Disp Rotate Process
// Input Value  : None
// Output Value : None
//--------------------------------------------------
void MFunctionPageDispRotateProc(void)
{
    switch(GET_KEYMESSAGE())
    {
        case _MENU_KEY_MESSAGE:
        case _UP_KEY_MESSAGE:
        case _DOWN_KEY_MESSAGE:
        	OsdDispNextSubItemProcess(_FUNCTION_PAGE_START,_FUNCTION_PAGE_END);
            break;
			
		case _LEFT_KEY_MESSAGE:
		case _RIGHT_KEY_MESSAGE:
            if(SysModeGetModeState() == _MODE_STATUS_ACTIVE)
            {
                OsdItemValueUpdate(_FUNCTION_PAGE_ROTATION, GET_OSD_DISP_ROTATE(),ucCurrRow,_ITEM_ADJUST_COLOR);

                SysModeSetResetTarget(_MODE_ACTION_RESET_TO_DISPLAY_SETTING);
                ScalerTimerReactiveTimerEvent(SEC(_OSD_DATA_SAVE_TIME), _USER_TIMER_EVENT_SAVE_USER_DATA_MSG);
            }
			break;
			
        case _EXIT_KEY_MESSAGE:
	        OsdDispUpdateSubMenuStatus(GET_OSD_STATE(), _ST_NORMAL);
            OsdFuncCloseWindow(_OSD_SUB_SELECT_WIN);
	        SET_OSD_STATE(_MAIN_FUNCTION);
            break;

        default:
            break;
    }
}
//--------------------------------------------------
// Description  : Disp Clone Process
// Input Value  : None
// Output Value : None
//--------------------------------------------------
void MFunctionPageDispCloneProc(void)
{
    switch(GET_KEYMESSAGE())
    {
        case _MENU_KEY_MESSAGE:
        case _UP_KEY_MESSAGE:
        case _DOWN_KEY_MESSAGE:
        	OsdDispNextSubItemProcess(_FUNCTION_PAGE_START,_FUNCTION_PAGE_END);
            break;
			
		case _LEFT_KEY_MESSAGE:
		case _RIGHT_KEY_MESSAGE:
            OsdItemValueUpdate(_FUNCTION_PAGE_INPUT_CLONE, GET_OSD_CLONE_MODE(),ucCurrRow,_ITEM_ADJUST_COLOR);
            ScalerTimerReactiveTimerEvent(SEC(_OSD_DATA_SAVE_TIME), _USER_TIMER_EVENT_SAVE_USER_DATA_MSG);
			break;
			
        case _EXIT_KEY_MESSAGE:
	        OsdDispUpdateSubMenuStatus(GET_OSD_STATE(), _ST_NORMAL);
            OsdFuncCloseWindow(_OSD_SUB_SELECT_WIN);
	        SET_OSD_STATE(_MAIN_FUNCTION);
            break;

        default:
            break;
    }
}
//OSD Page
//--------------------------------------------------
// Description  : OSD H Pos Process
// Input Value  : None
// Output Value : None
//--------------------------------------------------
void MOSDPageHPostionProc(void)
{
    switch(GET_KEYMESSAGE())
    {
        case _MENU_KEY_MESSAGE:
        case _UP_KEY_MESSAGE:
        case _DOWN_KEY_MESSAGE:
        	OsdDispNextSubItemProcess(_OSD_PAGE_START,_OSD_PAGE_END);
            break;
			
		case _LEFT_KEY_MESSAGE:
		case _RIGHT_KEY_MESSAGE:
            OsdItemValueUpdate(_OSD_PAGE_OSD_H_POS, GET_OSD_HPOS(),ucCurrRow,_ITEM_ADJUST_COLOR);
            OsdDispSetPosition(_POS_PERCENT, _OSD_POSITION_GLOBAL_A, GET_OSD_HPOS(), GET_OSD_VPOS());
            ScalerTimerReactiveTimerEvent(SEC(_OSD_DATA_SAVE_TIME), _USER_TIMER_EVENT_SAVE_USER_DATA_MSG);
			break;
			
        case _EXIT_KEY_MESSAGE:
	        OsdDispUpdateSubMenuStatus(GET_OSD_STATE(), _ST_NORMAL);
            OsdFuncCloseWindow(_OSD_SUB_SELECT_WIN);
	        SET_OSD_STATE(_MAIN_OSD);
            break;

        default:
            break;
    }
}
//--------------------------------------------------
// Description  : OSD V Pos Process
// Input Value  : None
// Output Value : None
//--------------------------------------------------
void MOSDPageVPostionProc(void)
{
    switch(GET_KEYMESSAGE())
    {
        case _MENU_KEY_MESSAGE:
        case _UP_KEY_MESSAGE:
        case _DOWN_KEY_MESSAGE:
        	OsdDispNextSubItemProcess(_OSD_PAGE_START,_OSD_PAGE_END);
            break;
			
		case _LEFT_KEY_MESSAGE:
		case _RIGHT_KEY_MESSAGE:
            OsdItemValueUpdate(_OSD_PAGE_OSD_V_POS, GET_OSD_VPOS(),ucCurrRow,_ITEM_ADJUST_COLOR);
            OsdDispSetPosition(_POS_PERCENT, _OSD_POSITION_GLOBAL_A, GET_OSD_HPOS(), GET_OSD_VPOS());
            ScalerTimerReactiveTimerEvent(SEC(_OSD_DATA_SAVE_TIME), _USER_TIMER_EVENT_SAVE_USER_DATA_MSG);
			break;
			
        case _EXIT_KEY_MESSAGE:
	        OsdDispUpdateSubMenuStatus(GET_OSD_STATE(), _ST_NORMAL);
            OsdFuncCloseWindow(_OSD_SUB_SELECT_WIN);
	        SET_OSD_STATE(_MAIN_OSD);
            break;

        default:
            break;
    }
}
//--------------------------------------------------
// Description  : OSD Transparency Process
// Input Value  : None
// Output Value : None
//--------------------------------------------------
void MOSDPageTransparencyProc(void)
{
    switch(GET_KEYMESSAGE())
    {
        case _MENU_KEY_MESSAGE:
        case _UP_KEY_MESSAGE:
        case _DOWN_KEY_MESSAGE:
        	OsdDispNextSubItemProcess(_OSD_PAGE_START,_OSD_PAGE_END);
            break;
			
		case _LEFT_KEY_MESSAGE:
		case _RIGHT_KEY_MESSAGE:
            OsdItemValueUpdate(_OSD_PAGE_OSD_TRANSPARENCY, GET_OSD_TRANSPARENCY_STATUS(),ucCurrRow,_ITEM_ADJUST_COLOR);
            OsdFuncTransparency(GET_OSD_TRANSPARENCY_STATUS());
            ScalerTimerReactiveTimerEvent(SEC(_OSD_DATA_SAVE_TIME), _USER_TIMER_EVENT_SAVE_USER_DATA_MSG);
			break;
			
        case _EXIT_KEY_MESSAGE:
	        OsdDispUpdateSubMenuStatus(GET_OSD_STATE(), _ST_NORMAL);
            OsdFuncCloseWindow(_OSD_SUB_SELECT_WIN);
	        SET_OSD_STATE(_MAIN_OSD);
            break;

        default:
            break;
    }
}
//--------------------------------------------------
// Description  : OSD Language Process
// Input Value  : None
// Output Value : None
//--------------------------------------------------
void MOSDPageLanugageProc(void)
{
    switch(GET_KEYMESSAGE())
    {
        case _MENU_KEY_MESSAGE:
        case _UP_KEY_MESSAGE:
        case _DOWN_KEY_MESSAGE:
        	OsdDispNextSubItemProcess(_OSD_PAGE_START,_OSD_PAGE_END);
            break;
			
		case _LEFT_KEY_MESSAGE:
		case _RIGHT_KEY_MESSAGE:
            OsdItemValueUpdate(_OSD_PAGE_OSD_LANGUAGE, GET_OSD_LANGUAGE(),ucCurrRow,_ITEM_ADJUST_COLOR);

            // Main Menu
            DrawMainItem(_MAIN_OSD);
            
            // Sub Menu
            DrawSubMenu(_MAIN_OSD); 

            OsdFuncClearOsd(ROW(_OSD_INFO_AREA_ROW_START), COL(_OSD_INFO_AREA_COL_START), WIDTH(_OSD_INFO_AREA_WIDTH), HEIGHT(_OSD_INFO_AREA_HEIGHT));
            //Input Info
            DrawInputInfo();

            ScalerTimerReactiveTimerEvent(SEC(_OSD_DATA_SAVE_TIME), _USER_TIMER_EVENT_SAVE_USER_DATA_MSG);

			break;
			
        case _EXIT_KEY_MESSAGE:
	        OsdDispUpdateSubMenuStatus(GET_OSD_STATE(), _ST_NORMAL);
            OsdFuncCloseWindow(_OSD_SUB_SELECT_WIN);
	        SET_OSD_STATE(_MAIN_OSD);
            break;

        default:
            break;
    }
}
//--------------------------------------------------
// Description  : OSD Rotate Process
// Input Value  : None
// Output Value : None
//--------------------------------------------------
void MOSDPageRotateProc(void)
{
    switch(GET_KEYMESSAGE())
    {
        case _MENU_KEY_MESSAGE:
        case _UP_KEY_MESSAGE:
        case _DOWN_KEY_MESSAGE:
        	OsdDispNextSubItemProcess(_OSD_PAGE_START,_OSD_PAGE_END);
            break;
			
		case _LEFT_KEY_MESSAGE:
		case _RIGHT_KEY_MESSAGE:
            OsdItemValueUpdate(_OSD_PAGE_OSD_ROTATE, GET_OSD_ROTATE_STATUS(),ucCurrRow,_ITEM_ADJUST_COLOR);
			#if((_OSD_ROTATE_FUNCTION == _OSD_ROTATE_SOFTWARE) || (_OSD_ROTATE_FUNCTION == _OSD_ROTATE_HARDWARE))
            OsdDispOsdRotateSwitch();
			#endif
            ScalerTimerReactiveTimerEvent(SEC(_OSD_DATA_SAVE_TIME), _USER_TIMER_EVENT_SAVE_USER_DATA_MSG);
			break;
			
        case _EXIT_KEY_MESSAGE:
	        OsdDispUpdateSubMenuStatus(GET_OSD_STATE(), _ST_NORMAL);
            OsdFuncCloseWindow(_OSD_SUB_SELECT_WIN);
	        SET_OSD_STATE(_MAIN_OSD);
            break;

        default:
            break;
    }
}

//--------------------------------------------------
// Description  : OSD Reset Process
// Input Value  : None
// Output Value : None
//--------------------------------------------------
void MOSDPageResetProc(void)
{
    switch(GET_KEYMESSAGE())
    {
        case _MENU_KEY_MESSAGE:
        case _UP_KEY_MESSAGE:
        case _DOWN_KEY_MESSAGE:
        	OsdDispNextSubItemProcess(_OSD_PAGE_START,_OSD_PAGE_END);
            break;
			
		case _LEFT_KEY_MESSAGE:
		case _RIGHT_KEY_MESSAGE:
		case _ENTER_KEY_MESSAGE:
            OsdDispOsdReset();
			break;
			
        case _EXIT_KEY_MESSAGE:
	        OsdDispUpdateSubMenuStatus(GET_OSD_STATE(), _ST_NORMAL);
            OsdFuncCloseWindow(_OSD_SUB_SELECT_WIN);
	        SET_OSD_STATE(_MAIN_OSD);
            break;

        default:
            break;
    }
}
//Audio Page
//--------------------------------------------------
// Description  : Volume Process
// Input Value  : None
// Output Value : None
//--------------------------------------------------
void MAudioPageVolumeProc(void)
{
    switch(GET_KEYMESSAGE())
    {
        case _MENU_KEY_MESSAGE:
        case _UP_KEY_MESSAGE:
        case _DOWN_KEY_MESSAGE:
        	OsdDispNextSubItemProcess(_AUDIO_PAGE_START,_AUDIO_PAGE_END);
            break;
			
		case _LEFT_KEY_MESSAGE:
		case _RIGHT_KEY_MESSAGE:
            OsdItemValueUpdate(_AUDIO_PAGE_VOLUME, GET_OSD_VOLUME(),ucCurrRow,_ITEM_ADJUST_COLOR);
            /*if((GET_OSD_VOLUME_MUTE() == _ON) && (g_usBackupValue == GET_OSD_VOLUME()))
            {
                // RTDOsdDispOsdFunctionAdjust(_MENU_AUDIO_MUTE_ON_OFF);
                SET_OSD_VOLUME_MUTE(_OFF);
            }*/
			#if(_AUDIO_SUPPORT == _ON)
            UserAdjustAudioVolume(GET_OSD_VOLUME());
			#endif
            ScalerTimerReactiveTimerEvent(SEC(_OSD_DATA_SAVE_TIME), _USER_TIMER_EVENT_SAVE_USER_DATA_MSG);
			break;
			
        case _EXIT_KEY_MESSAGE:
	        OsdDispUpdateSubMenuStatus(GET_OSD_STATE(), _ST_NORMAL);
            OsdFuncCloseWindow(_OSD_SUB_SELECT_WIN);
	        SET_OSD_STATE(_MAIN_AUDIO);
            break;

        default:
            break;
    }
}
//--------------------------------------------------
// Description  : Mute Process
// Input Value  : None
// Output Value : None
//--------------------------------------------------
void MAudioPageMuteProc(void)
{
    switch(GET_KEYMESSAGE())
    {
        case _MENU_KEY_MESSAGE:
        case _UP_KEY_MESSAGE:
        case _DOWN_KEY_MESSAGE:
        	OsdDispNextSubItemProcess(_AUDIO_PAGE_START,_AUDIO_PAGE_END);
            break;
			
		case _LEFT_KEY_MESSAGE:
		case _RIGHT_KEY_MESSAGE:
            OsdItemValueUpdate(_AUDIO_PAGE_MUTE, GET_OSD_VOLUME_MUTE(),ucCurrRow,_ITEM_ADJUST_COLOR);
			#if(_AUDIO_SUPPORT == _ON)
			#if(_USE_NS4263 == _OFF)
            UserAdjustAudioMuteSwitch();
            #endif
			#endif
            ScalerTimerReactiveTimerEvent(SEC(_OSD_DATA_SAVE_TIME), _USER_TIMER_EVENT_SAVE_USER_DATA_MSG);
			break;
			
        case _EXIT_KEY_MESSAGE:
	        OsdDispUpdateSubMenuStatus(GET_OSD_STATE(), _ST_NORMAL);
            OsdFuncCloseWindow(_OSD_SUB_SELECT_WIN);
	        SET_OSD_STATE(_MAIN_AUDIO);
            break;

        default:
            break;
    }
}
//--------------------------------------------------
// Description  : Audio Source Process
// Input Value  : None
// Output Value : None
//--------------------------------------------------
void MAudioPageAudioSourceProc(void)
{
    switch(GET_KEYMESSAGE())
    {
        case _MENU_KEY_MESSAGE:
        case _UP_KEY_MESSAGE:
        case _DOWN_KEY_MESSAGE:
        	OsdDispNextSubItemProcess(_AUDIO_PAGE_START,_AUDIO_PAGE_END);
            break;
			
		case _LEFT_KEY_MESSAGE:
		case _RIGHT_KEY_MESSAGE:
            OsdItemValueUpdate(_AUDIO_PAGE_SOURCE, GET_OSD_AUDIO_SOURCE(),ucCurrRow,_ITEM_ADJUST_COLOR);
            ScalerTimerReactiveTimerEvent(SEC(_OSD_DATA_SAVE_TIME), _USER_TIMER_EVENT_SAVE_USER_DATA_MSG);
			break;
			
        case _EXIT_KEY_MESSAGE:
	        OsdDispUpdateSubMenuStatus(GET_OSD_STATE(), _ST_NORMAL);
            OsdFuncCloseWindow(_OSD_SUB_SELECT_WIN);
	        SET_OSD_STATE(_MAIN_AUDIO);
            break;

        default:
            break;
    }
}
//ServiceLevel2 Page
//--------------------------------------------------
// Description  : ServiceLevel2 Page1 Process
// Input Value  : None
// Output Value : None
//--------------------------------------------------
void MenuServiceLevel2Page1(void)
{
    switch(GET_KEYMESSAGE())
    {
        case _RIGHT_KEY_MESSAGE:
	        ucStartItem = OsdFuncGetStartEndItem(_SERVICELEVEL2_PAGE1_END,_SERVICELEVEL2_PAGE1_START, _SERVICELEVEL2_PAGE1_END,_INC,1);
	        ucEndItem 	= OsdFuncGetStartEndItem(ucStartItem,	 _SERVICELEVEL2_PAGE1_START, _SERVICELEVEL2_PAGE1_END,_INC,(((_SERVICELEVEL2_PAGE1_END - ucStartItem) >= _OSD_ITEM_COUNT)?_OSD_ITEM_COUNT:(_SERVICELEVEL2_PAGE1_END - ucStartItem)));
                
	        SET_OSD_STATE(OsdFuncGetVilidOsdState(_SERVICELEVEL2_PAGE1_END,_SERVICELEVEL2_PAGE1_START, _SERVICELEVEL2_PAGE1_END, 1, _ON));
        
	        OsdDispUpdateSubMenuStatus(GET_OSD_STATE(), _ST_SELECT);
            break;

        case _MENU_KEY_MESSAGE:
        case _UP_KEY_MESSAGE:
        case _DOWN_KEY_MESSAGE:
            OsdDispNextServiceLevel2ItemProcess();
            break;

        case _EXIT_KEY_MESSAGE:
            ucEnterServiceLevel_flag = _FALSE;
            OsdFuncCloseWindow(_OSD_SUB_SELECT_WIN);
	        SET_OSD_STATE(_MAIN_SERVICE_LEVEL_2);
	        
            // Main Menu
            DrawMainItem(GET_OSD_STATE());
            
            // Sub Menu
	        DrawSubMenu(GET_OSD_STATE());
            break;

        default:
            break;
    }
}
//--------------------------------------------------
// Description  : ServiceLevel2 Page2 Process
// Input Value  : None
// Output Value : None
//--------------------------------------------------
void MenuServiceLevel2Page2(void)
{
    switch(GET_KEYMESSAGE())
    {
        case _RIGHT_KEY_MESSAGE:
            ucStartItem = OsdFuncGetStartEndItem(_SERVICELEVEL2_PAGE2_END,_SERVICELEVEL2_PAGE2_START, _SERVICELEVEL2_PAGE2_END,_INC,1);
            ucEndItem   = OsdFuncGetStartEndItem(ucStartItem,    _SERVICELEVEL2_PAGE2_START, _SERVICELEVEL2_PAGE2_END,_INC,(((_SERVICELEVEL2_PAGE2_END - ucStartItem) >= _OSD_ITEM_COUNT)?_OSD_ITEM_COUNT:(_SERVICELEVEL2_PAGE2_END - ucStartItem)));
                
            SET_OSD_STATE(OsdFuncGetVilidOsdState(_SERVICELEVEL2_PAGE2_END,_SERVICELEVEL2_PAGE2_START, _SERVICELEVEL2_PAGE2_END, 1, _ON));
        
            OsdDispUpdateSubMenuStatus(GET_OSD_STATE(), _ST_SELECT);
            break;

        case _MENU_KEY_MESSAGE:
        case _UP_KEY_MESSAGE:
        case _DOWN_KEY_MESSAGE:
            OsdDispNextServiceLevel2ItemProcess();
            break;

        case _EXIT_KEY_MESSAGE:
            ucEnterServiceLevel_flag = _FALSE;
            OsdFuncCloseWindow(_OSD_SUB_SELECT_WIN);
	        SET_OSD_STATE(_MAIN_SERVICE_LEVEL_2);
	        
            // Main Menu
            DrawMainItem(GET_OSD_STATE());
            
            // Sub Menu
	        DrawSubMenu(GET_OSD_STATE());
            break;

        default:
            break;
    }
}
//==============================================================================
//Analog Page
//==============================================================================
//--------------------------------------------------
// Description  : AutoAdjust Process
// Input Value  : None
// Output Value : None
//--------------------------------------------------
void MAnalogPageAutoAdjustProc(void)
{
#if(_VGA_SUPPORT == _ON)
    switch(GET_KEYMESSAGE())
    {
        case _MENU_KEY_MESSAGE:
        case _UP_KEY_MESSAGE:
        case _DOWN_KEY_MESSAGE:
        	OsdDispNextSubItemProcess(_ANALOG_PAGE_START,_ANALOG_PAGE_END);
            break;
			
		case _LEFT_KEY_MESSAGE:
		case _RIGHT_KEY_MESSAGE:
			#if(_VGA_SUPPORT == _ON)
                if(SysSourceGetSourceType() == _SOURCE_VGA)
                {
	                UserCommonAutoConfig();
                }
			#endif
			break;
			
        case _EXIT_KEY_MESSAGE:
	        OsdDispUpdateSubMenuStatus(GET_OSD_STATE(), _ST_NORMAL);
            OsdFuncCloseWindow(_OSD_SUB_SELECT_WIN);
	        SET_OSD_STATE(_MAIN_ANALOG);
            break;

        default:
            break;
    }
#endif
}
//--------------------------------------------------
// Description  : Disp H Pos Process
// Input Value  : None
// Output Value : None
//--------------------------------------------------
void MAnalogPageHPostionProc(void)
{
#if(_VGA_SUPPORT == _ON)
    switch(GET_KEYMESSAGE())
    {
        case _MENU_KEY_MESSAGE:
        case _UP_KEY_MESSAGE:
        case _DOWN_KEY_MESSAGE:
        	OsdDispNextSubItemProcess(_ANALOG_PAGE_START,_ANALOG_PAGE_END);
            break;
			
		case _LEFT_KEY_MESSAGE:
		case _RIGHT_KEY_MESSAGE:
            OsdItemValueUpdate(_ANALOG_PAGE_H_POS, GET_VGA_MODE_ADJUST_H_POSITION(),ucCurrRow,_ITEM_ADJUST_COLOR);
            UserCommonAdjustHPosition(GET_VGA_MODE_ADJUST_H_POSITION());
            ScalerTimerReactiveTimerEvent(SEC(_OSD_DATA_SAVE_TIME), _USER_TIMER_EVENT_SAVE_MODE_USER_DATA_MSG);
			break;
			
        case _EXIT_KEY_MESSAGE:
	        OsdDispUpdateSubMenuStatus(GET_OSD_STATE(), _ST_NORMAL);
            OsdFuncCloseWindow(_OSD_SUB_SELECT_WIN);
	        SET_OSD_STATE(_MAIN_ANALOG);
            break;

        default:
            break;
    }
#endif
}
//--------------------------------------------------
// Description  : Disp V Pos Process
// Input Value  : None
// Output Value : None
//--------------------------------------------------
void MAnalogPageVPostionProc(void)
{
#if(_VGA_SUPPORT == _ON)
    switch(GET_KEYMESSAGE())
    {
        case _MENU_KEY_MESSAGE:
        case _UP_KEY_MESSAGE:
        case _DOWN_KEY_MESSAGE:
        	OsdDispNextSubItemProcess(_ANALOG_PAGE_START,_ANALOG_PAGE_END);
            break;
			
		case _LEFT_KEY_MESSAGE:
		case _RIGHT_KEY_MESSAGE:
            OsdItemValueUpdate(_ANALOG_PAGE_V_POS, GET_VGA_MODE_ADJUST_V_POSITION(),ucCurrRow,_ITEM_ADJUST_COLOR);
            UserCommonAdjustVPosition(GET_VGA_MODE_ADJUST_V_POSITION());
            ScalerTimerReactiveTimerEvent(SEC(_OSD_DATA_SAVE_TIME), _USER_TIMER_EVENT_SAVE_MODE_USER_DATA_MSG);
			break;
			
        case _EXIT_KEY_MESSAGE:
	        OsdDispUpdateSubMenuStatus(GET_OSD_STATE(), _ST_NORMAL);
            OsdFuncCloseWindow(_OSD_SUB_SELECT_WIN);
	        SET_OSD_STATE(_MAIN_ANALOG);
            break;

        default:
            break;
    }
#endif
}
//--------------------------------------------------
// Description  : Disp Clock Process
// Input Value  : None
// Output Value : None
//--------------------------------------------------
void MAnalogPageClockProc(void)
{
#if(_VGA_SUPPORT == _ON)
    switch(GET_KEYMESSAGE())
    {
        case _MENU_KEY_MESSAGE:
        case _UP_KEY_MESSAGE:
        case _DOWN_KEY_MESSAGE:
        	OsdDispNextSubItemProcess(_ANALOG_PAGE_START,_ANALOG_PAGE_END);
            break;
			
		case _LEFT_KEY_MESSAGE:
		case _RIGHT_KEY_MESSAGE:
            OsdItemValueUpdate(_ANALOG_PAGE_CLOCK, GET_VGA_MODE_ADJUST_CLOCK(),ucCurrRow,_ITEM_ADJUST_COLOR);
            UserCommonAdjustClock(GET_VGA_MODE_ADJUST_CLOCK());
            ScalerTimerReactiveTimerEvent(SEC(_OSD_DATA_SAVE_TIME), _USER_TIMER_EVENT_SAVE_MODE_USER_DATA_MSG);
			break;
			
        case _EXIT_KEY_MESSAGE:
	        OsdDispUpdateSubMenuStatus(GET_OSD_STATE(), _ST_NORMAL);
            OsdFuncCloseWindow(_OSD_SUB_SELECT_WIN);
	        SET_OSD_STATE(_MAIN_ANALOG);
            break;

        default:
            break;
    }
#endif
}
//--------------------------------------------------
// Description  : Disp Phase Process
// Input Value  : None
// Output Value : None
//--------------------------------------------------
void MAnalogPagePhaseProc(void)
{
#if(_VGA_SUPPORT == _ON)
    switch(GET_KEYMESSAGE())
    {
        case _MENU_KEY_MESSAGE:
        case _UP_KEY_MESSAGE:
        case _DOWN_KEY_MESSAGE:
        	OsdDispNextSubItemProcess(_ANALOG_PAGE_START,_ANALOG_PAGE_END);
            break;
			
		case _LEFT_KEY_MESSAGE:
		case _RIGHT_KEY_MESSAGE:
            OsdItemValueUpdate(_ANALOG_PAGE_PHASE, GET_VGA_MODE_ADJUST_PHASE(),ucCurrRow,_ITEM_ADJUST_COLOR);
            UserCommonAdjustPhase(GET_VGA_MODE_ADJUST_PHASE());
            ScalerTimerReactiveTimerEvent(SEC(_OSD_DATA_SAVE_TIME), _USER_TIMER_EVENT_SAVE_MODE_USER_DATA_MSG);
			break;
			
        case _EXIT_KEY_MESSAGE:
	        OsdDispUpdateSubMenuStatus(GET_OSD_STATE(), _ST_NORMAL);
            OsdFuncCloseWindow(_OSD_SUB_SELECT_WIN);
	        SET_OSD_STATE(_MAIN_ANALOG);
            break;

        default:
            break;
    }
#endif
}
//==============================================================================
//ServiceLevel2 Page1
//==============================================================================
//--------------------------------------------------
// Description  : Hue Process
// Input Value  : None
// Output Value : None
//--------------------------------------------------
void MServiceLevel2Page1HueProc(void)
{
    switch(GET_KEYMESSAGE())
    {
        case _MENU_KEY_MESSAGE:
        case _UP_KEY_MESSAGE:
        case _DOWN_KEY_MESSAGE:
        	OsdDispNextSubItemProcess(_SERVICELEVEL2_PAGE1_START,_SERVICELEVEL2_PAGE1_END);
            break;
			
		case _LEFT_KEY_MESSAGE:
		case _RIGHT_KEY_MESSAGE:
	        OsdItemValueUpdate(_SERVICELEVEL2_PAGE1_HUE, GET_OSD_HUE(),ucCurrRow,_ITEM_ADJUST_COLOR);
			#if(_GLOBAL_HUE_SATURATION == _ON)
            UserAdjustGlobalHueSat((SWORD)GET_OSD_HUE(), GET_OSD_SATURATION());
			#endif
            ScalerTimerReactiveTimerEvent(SEC(_OSD_DATA_SAVE_TIME), _USER_TIMER_EVENT_SAVE_USER_DATA_MSG);
			break;
			
        case _EXIT_KEY_MESSAGE:
	        OsdDispUpdateSubMenuStatus(GET_OSD_STATE(), _ST_NORMAL);
            OsdFuncCloseWindow(_OSD_SUB_SELECT_WIN);
	        SET_OSD_STATE(_SERVICELEVEL2_PAGE_1);
            break;

        default:
            break;
    }
}
//--------------------------------------------------
// Description  : Saturation Process
// Input Value  : None
// Output Value : None
//--------------------------------------------------
void MServiceLevel2Page1SaturationProc(void)
{
    switch(GET_KEYMESSAGE())
    {
        case _MENU_KEY_MESSAGE:
        case _UP_KEY_MESSAGE:
        case _DOWN_KEY_MESSAGE:
        	OsdDispNextSubItemProcess(_SERVICELEVEL2_PAGE1_START,_SERVICELEVEL2_PAGE1_END);
            break;
			
		case _LEFT_KEY_MESSAGE:
		case _RIGHT_KEY_MESSAGE:
	        OsdItemValueUpdate(_SERVICELEVEL2_PAGE1_SATURATION, GET_OSD_SATURATION(),ucCurrRow,_ITEM_ADJUST_COLOR);
			#if(_GLOBAL_HUE_SATURATION == _ON)
            UserAdjustGlobalHueSat((SWORD)GET_OSD_HUE(), GET_OSD_SATURATION());
			#endif
            ScalerTimerReactiveTimerEvent(SEC(_OSD_DATA_SAVE_TIME), _USER_TIMER_EVENT_SAVE_USER_DATA_MSG);
			break;
			
        case _EXIT_KEY_MESSAGE:
	        OsdDispUpdateSubMenuStatus(GET_OSD_STATE(), _ST_NORMAL);
            OsdFuncCloseWindow(_OSD_SUB_SELECT_WIN);
	        SET_OSD_STATE(_SERVICELEVEL2_PAGE_1);
            break;

        default:
            break;
    }
}
//--------------------------------------------------
// Description  : Sharpness Process
// Input Value  : None
// Output Value : None
//--------------------------------------------------
void MServiceLevel2Page1SharpnessProc(void)
{
    switch(GET_KEYMESSAGE())
    {
        case _MENU_KEY_MESSAGE:
        case _UP_KEY_MESSAGE:
        case _DOWN_KEY_MESSAGE:
        	OsdDispNextSubItemProcess(_SERVICELEVEL2_PAGE1_START,_SERVICELEVEL2_PAGE1_END);
            break;
			
		case _LEFT_KEY_MESSAGE:
		case _RIGHT_KEY_MESSAGE:
	        OsdItemValueUpdate(_SERVICELEVEL2_PAGE1_SHARPNESS, GET_OSD_SHARPNESS(),ucCurrRow,_ITEM_ADJUST_COLOR);
            ScalerTimerWaitForEvent(_EVENT_DEN_STOP);
			#if(_SHARPNESS_SUPPORT == _ON)
            UserCommonAdjustSharpness(SysSourceGetInputPort());
			#endif
            ScalerTimerReactiveTimerEvent(SEC(_OSD_DATA_SAVE_TIME), _USER_TIMER_EVENT_SAVE_USER_DATA_MSG);
			break;
			
        case _EXIT_KEY_MESSAGE:
	        OsdDispUpdateSubMenuStatus(GET_OSD_STATE(), _ST_NORMAL);
            OsdFuncCloseWindow(_OSD_SUB_SELECT_WIN);
	        SET_OSD_STATE(_SERVICELEVEL2_PAGE_1);
            break;

        default:
            break;
    }
}
//--------------------------------------------------
// Description  : PCM Process
// Input Value  : None
// Output Value : None
//--------------------------------------------------
void MServiceLevel2Page1PCMProc(void)
{
#if(_PCM_FUNCTION == _ON)
    switch(GET_KEYMESSAGE())
    {
        case _MENU_KEY_MESSAGE:
        case _UP_KEY_MESSAGE:
        case _DOWN_KEY_MESSAGE:
        	OsdDispNextSubItemProcess(_SERVICELEVEL2_PAGE1_START,_SERVICELEVEL2_PAGE1_END);
            break;
			
		case _LEFT_KEY_MESSAGE:
		case _RIGHT_KEY_MESSAGE:
	        OsdItemValueUpdate(_SERVICELEVEL2_PAGE1_PCM, GET_OSD_PCM_STATUS(),ucCurrRow,_ITEM_ADJUST_COLOR);
            OsdFuncColorPcmAdjust();
            ScalerTimerReactiveTimerEvent(SEC(_OSD_DATA_SAVE_TIME), _USER_TIMER_EVENT_SAVE_USER_DATA_MSG);
			break;
			
        case _EXIT_KEY_MESSAGE:
	        OsdDispUpdateSubMenuStatus(GET_OSD_STATE(), _ST_NORMAL);
            OsdFuncCloseWindow(_OSD_SUB_SELECT_WIN);
	        SET_OSD_STATE(_SERVICELEVEL2_PAGE_1);
            break;

        default:
            break;
    }
#endif
}
//--------------------------------------------------
// Description  : HDR Mode Process
// Input Value  : None
// Output Value : None
//--------------------------------------------------
void MServiceLevel2Page1HDRModeProc(void)
{
#if(_ULTRA_HDR_SUPPORT == _ON)
    switch(GET_KEYMESSAGE())
    {
        case _MENU_KEY_MESSAGE:
        case _UP_KEY_MESSAGE:
        case _DOWN_KEY_MESSAGE:
        	OsdDispNextSubItemProcess(_SERVICELEVEL2_PAGE1_START,_SERVICELEVEL2_PAGE1_END);
            break;
			
		case _LEFT_KEY_MESSAGE:
		case _RIGHT_KEY_MESSAGE:
			#if(_HDR10_SUPPORT == _ON)
	        OsdItemValueUpdate(_SERVICELEVEL2_PAGE1_HDR, GET_OSD_HDR_MODE(),ucCurrRow,_ITEM_ADJUST_COLOR);
			#if(_EMBEDDED_EDID_SUPPORT == _ON)
            UserCommonInterfaceLoadEmbeddedEdidData();
			#endif
            UserCommonHDR10SupportSwitch();
            UserCommonHDRAdjust(_HDR_FLOW_OSD_MODE_CHANGE);
            ScalerTimerReactiveTimerEvent(SEC(_OSD_DATA_SAVE_TIME), _USER_TIMER_EVENT_SAVE_USER_DATA_MSG);
            #endif
			break;
			
        case _EXIT_KEY_MESSAGE:
	        OsdDispUpdateSubMenuStatus(GET_OSD_STATE(), _ST_NORMAL);
            OsdFuncCloseWindow(_OSD_SUB_SELECT_WIN);
	        SET_OSD_STATE(_SERVICELEVEL2_PAGE_1);
            break;

        default:
            break;
    }
#endif
}
//==============================================================================
//ServiceLevel2 Page2
//==============================================================================
//--------------------------------------------------
// Description  : Freeze Process
// Input Value  : None
// Output Value : None
//--------------------------------------------------
void MServiceLevel2Page2FreezeProc(void)
{
#if(_FREEZE_SUPPORT == _ON)
    switch(GET_KEYMESSAGE())
    {
        case _MENU_KEY_MESSAGE:
        case _UP_KEY_MESSAGE:
        case _DOWN_KEY_MESSAGE:
        	OsdDispNextSubItemProcess(_SERVICELEVEL2_PAGE2_START,_SERVICELEVEL2_PAGE2_END);
            break;
			
		case _LEFT_KEY_MESSAGE:
		case _RIGHT_KEY_MESSAGE:
	        OsdItemValueUpdate(_SERVICELEVEL2_PAGE2_FREEZE, GET_OSD_FREEZE_STATUS(),ucCurrRow,_ITEM_ADJUST_COLOR);
            UserCommonAdjustDisplayFreeze(GET_OSD_FREEZE_STATUS());
            ScalerTimerReactiveTimerEvent(SEC(_OSD_DATA_SAVE_TIME), _USER_TIMER_EVENT_SAVE_USER_DATA_MSG);
			break;
			
        case _EXIT_KEY_MESSAGE:
	        OsdDispUpdateSubMenuStatus(GET_OSD_STATE(), _ST_NORMAL);
            OsdFuncCloseWindow(_OSD_SUB_SELECT_WIN);
	        SET_OSD_STATE(_SERVICELEVEL2_PAGE_2);
            break;

        default:
            break;
    }
#endif
}
//--------------------------------------------------
// Description  : DP MST Process
// Input Value  : None
// Output Value : None
//--------------------------------------------------
void MServiceLevel2Page2DPMstProc(void)
{
#if(_DP_MST_SUPPORT == _ON)
    switch(GET_KEYMESSAGE())
    {
        case _MENU_KEY_MESSAGE:
        case _UP_KEY_MESSAGE:
        case _DOWN_KEY_MESSAGE:
        	OsdDispNextSubItemProcess(_SERVICELEVEL2_PAGE2_START,_SERVICELEVEL2_PAGE2_END);
            break;
			
		case _LEFT_KEY_MESSAGE:
		case _RIGHT_KEY_MESSAGE:
	        OsdItemValueUpdate(_SERVICELEVEL2_PAGE2_MST, GET_OSD_DP_MST(),ucCurrRow,_ITEM_ADJUST_COLOR);
            ScalerTimerReactiveTimerEvent(SEC(_OSD_DATA_SAVE_TIME), _USER_TIMER_EVENT_SAVE_USER_DATA_MSG);
			break;
			
        case _EXIT_KEY_MESSAGE:
	        OsdDispUpdateSubMenuStatus(GET_OSD_STATE(), _ST_NORMAL);
            OsdFuncCloseWindow(_OSD_SUB_SELECT_WIN);
	        SET_OSD_STATE(_SERVICELEVEL2_PAGE_2);
            break;

        default:
            break;
    }
#endif
}
//--------------------------------------------------
// Description  : Hotkey Source Process
// Input Value  : None
// Output Value : None
//--------------------------------------------------
void MHotKeySource(void)
{
	BYTE ucPrevSourceItem = GetSourceIndex(GET_OSD_INPUT_PORT_OSD_ITEM());

	if(GET_KEYMESSAGE() == _SOURCE_KEY_MESSAGE)
	{
		SET_KEYMESSAGE(_RIGHT_KEY_MESSAGE);
	}
	
    switch(GET_KEYMESSAGE())
    {
        case _MENU_KEY_MESSAGE:
            if(GET_OSD_DP_VERSION_HOTKEY_DISP() == _OFF)
            {
                if(g_usBackupValue != GET_OSD_INPUT_PORT_OSD_ITEM())
                {
                    OsdFuncChangeSource();
                }
                else
                {
                    if(SysModeGetModeState() == _MODE_STATUS_NOSUPPORT)
                    {
                        SysPowerSetTargetPowerStatus(_POWER_STATUS_NOSUPPORT_SAVING);
                    }
                    else if((SysModeGetModeState() == _MODE_STATUS_POWER_SAVING) ||
                            (SysModeGetModeState() == _MODE_STATUS_NOSIGNAL))
                    {
                        ScalerTimerReactiveTimerEvent(SEC(0), _USER_TIMER_EVENT_OSD_SHOW_POWER_SAVING);
                    }
                    else
                    {
                        OsdDispDisableOsd();
                    }
                }
                SET_OSD_STATE(_MENU_NONE);
            }

            break;

        case _RIGHT_KEY_MESSAGE:
        case _DOWN_KEY_MESSAGE:
            OsdFuncOsdLine(ROW(_OSD_SOURCE_ITEM_ROW_START + GetSourceIndex(GET_OSD_INPUT_PORT_OSD_ITEM())*_OSD_ITEM_SPACE),COL(0), WIDTH(g_ucOsdWidth), HEIGHT(1), _SUB_NORMAL_COLOR, _OSD_BYTE2);
        	SET_OSD_INPUT_PORT_OSD_ITEM(OsdFuncCheckInputPortType(GET_OSD_INPUT_PORT_OSD_ITEM()));
			
            OsdFuncOsdLine(ROW(_OSD_SOURCE_ITEM_ROW_START + GetSourceIndex(GET_OSD_INPUT_PORT_OSD_ITEM())*_OSD_ITEM_SPACE),COL(0), WIDTH(g_ucOsdWidth), HEIGHT(1), _SUB_SELECT_COLOR, _OSD_BYTE2);
            OsdDispHotKeySourceMenuSwitch();

            if((SysModeGetModeState() == _MODE_STATUS_POWER_SAVING) ||
               (SysModeGetModeState() == _MODE_STATUS_NOSIGNAL))
            {
                ScalerTimerReactiveTimerEvent(SEC(3), _USER_TIMER_EVENT_OSD_SHOW_POWER_SAVING);
            }
            ScalerTimerReactiveTimerEvent(SEC(_OSD_DATA_SAVE_TIME), _USER_TIMER_EVENT_SAVE_USER_DATA_MSG);
            break;

        case _LEFT_KEY_MESSAGE:
        case _UP_KEY_MESSAGE:
            OsdFuncOsdLine(ROW(_OSD_SOURCE_ITEM_ROW_START + GetSourceIndex(GET_OSD_INPUT_PORT_OSD_ITEM())*_OSD_ITEM_SPACE),COL(0), WIDTH(g_ucOsdWidth), HEIGHT(1), _SUB_NORMAL_COLOR, _OSD_BYTE2);
        	SET_OSD_INPUT_PORT_OSD_ITEM(OsdFuncCheckInputPortType(GET_OSD_INPUT_PORT_OSD_ITEM()));

            OsdFuncOsdLine(ROW(_OSD_SOURCE_ITEM_ROW_START + GetSourceIndex(GET_OSD_INPUT_PORT_OSD_ITEM())*_OSD_ITEM_SPACE),COL(0), WIDTH(g_ucOsdWidth), HEIGHT(1), _SUB_SELECT_COLOR, _OSD_BYTE2);

            OsdDispHotKeySourceMenuSwitch();

            if((SysModeGetModeState() == _MODE_STATUS_POWER_SAVING) ||
               (SysModeGetModeState() == _MODE_STATUS_NOSIGNAL))
            {
                ScalerTimerReactiveTimerEvent(SEC(3), _USER_TIMER_EVENT_OSD_SHOW_POWER_SAVING);
            }
            ScalerTimerReactiveTimerEvent(SEC(_OSD_DATA_SAVE_TIME), _USER_TIMER_EVENT_SAVE_USER_DATA_MSG);

            break;

        case _EXIT_KEY_MESSAGE:
            if(g_usBackupValue != GET_OSD_INPUT_PORT_OSD_ITEM())
            {
                SET_OSD_INPUT_PORT_OSD_ITEM(g_usBackupValue);
                SET_OSD_EVENT_MESSAGE(_OSDEVENT_SAVE_NVRAM_OSDUSERDATA_MSG);
            }

            if(SysModeGetModeState() == _MODE_STATUS_NOSUPPORT)
            {
                SysPowerSetTargetPowerStatus(_POWER_STATUS_NOSUPPORT_SAVING);
            }
            else if((SysModeGetModeState() == _MODE_STATUS_POWER_SAVING) ||
                    (SysModeGetModeState() == _MODE_STATUS_NOSIGNAL))
            {//Mark2020-06-30
                //ScalerTimerReactiveTimerEvent(SEC(0), _USER_TIMER_EVENT_OSD_SHOW_POWER_SAVING);
            }
            else
            {
                OsdDispDisableOsd();
            }
            OsdDispDisableOsd();//Mark2020-06-30

            break;

        default:
            break;
    }
}
//--------------------------------------------------
// Description  : Hotkey Backlight Process
// Input Value  : None
// Output Value : None
//--------------------------------------------------
void MHotKeyBacklight(void)
{
	if(GET_KEYMESSAGE() == _BACKLIGHT_DEC_KEY_MESSAGE)
	{
		SET_KEYMESSAGE(_LEFT_KEY_MESSAGE);
	}
	else if(GET_KEYMESSAGE() == _BACKLIGHT_INC_KEY_MESSAGE)
	{
		SET_KEYMESSAGE(_RIGHT_KEY_MESSAGE);
	}
	
    switch(GET_KEYMESSAGE())
    {
        case _RIGHT_KEY_MESSAGE:
        case _LEFT_KEY_MESSAGE:
            OsdDispHotKeyOptionMenuSwitch(_HOTKEY_BACKLIGHT);
            ScalerTimerReactiveTimerEvent(SEC(_OSD_DATA_SAVE_TIME), _USER_TIMER_EVENT_SAVE_USER_DATA_MSG);
            break;

        case _MENU_KEY_MESSAGE:
        case _EXIT_KEY_MESSAGE:
            OsdDispDisableOsd();
            break;

        default:
            break;
    }
}
//--------------------------------------------------
// Description  : Hotkey Volume Process
// Input Value  : None
// Output Value : None
//--------------------------------------------------
void MHotKeyVolume(void)
{	
	if(GET_KEYMESSAGE() == _VOL_DEC_KEY_MESSAGE)
	{
		SET_KEYMESSAGE(_LEFT_KEY_MESSAGE);
	}
	else if(GET_KEYMESSAGE() == _VOL_INC_KEY_MESSAGE)
	{
		SET_KEYMESSAGE(_RIGHT_KEY_MESSAGE);
	}

    switch(GET_KEYMESSAGE())
    {
        case _RIGHT_KEY_MESSAGE:
        case _LEFT_KEY_MESSAGE:
            OsdDispHotKeyOptionMenuSwitch(_HOTKEY_VOLUME);
            ScalerTimerReactiveTimerEvent(SEC(_OSD_DATA_SAVE_TIME), _USER_TIMER_EVENT_SAVE_USER_DATA_MSG);
            break;

        case _MENU_KEY_MESSAGE:
        case _EXIT_KEY_MESSAGE:
            OsdDispDisableOsd();
            break;

        default:
            break;
    }
}
//--------------------------------------------------
// Description  : Hotkey Brightness Process
// Input Value  : None
// Output Value : None
//--------------------------------------------------
void MHotKeyBrightness(void)
{
	if(GET_KEYMESSAGE() == _BRIGHTNESS_DEC_KEY_MESSAGE)
	{
		SET_KEYMESSAGE(_LEFT_KEY_MESSAGE);
	}
	else if(GET_KEYMESSAGE() == _BRIGHTNESS_INC_KEY_MESSAGE)
	{
		SET_KEYMESSAGE(_RIGHT_KEY_MESSAGE);
	}

    switch(GET_KEYMESSAGE())
    {
        case _RIGHT_KEY_MESSAGE:
        case _LEFT_KEY_MESSAGE:
            OsdDispHotKeyOptionMenuSwitch(_HOTKEY_BRIGHTNESS);
            ScalerTimerReactiveTimerEvent(SEC(_OSD_DATA_SAVE_TIME), _USER_TIMER_EVENT_SAVE_USER_DATA_MSG);
            break;

        case _MENU_KEY_MESSAGE:
        case _EXIT_KEY_MESSAGE:
            OsdDispDisableOsd();
            break;

        default:
            break;
    }
}
//--------------------------------------------------
// Description  : Hotkey Contrast Process
// Input Value  : None
// Output Value : None
//--------------------------------------------------
void MHotKeyContrast(void)
{
	if(GET_KEYMESSAGE() == _CONTRAST_DEC_KEY_MESSAGE)
	{
		SET_KEYMESSAGE(_LEFT_KEY_MESSAGE);
	}
	else if(GET_KEYMESSAGE() == _CONTRAST_INC_KEY_MESSAGE)
	{
		SET_KEYMESSAGE(_RIGHT_KEY_MESSAGE);
	}
	
    switch(GET_KEYMESSAGE())
    {
        case _RIGHT_KEY_MESSAGE:
        case _LEFT_KEY_MESSAGE:
            OsdDispHotKeyOptionMenuSwitch(_HOTKEY_CONTRAST);
            ScalerTimerReactiveTimerEvent(SEC(_OSD_DATA_SAVE_TIME), _USER_TIMER_EVENT_SAVE_USER_DATA_MSG);
            break;

        case _MENU_KEY_MESSAGE:
        case _EXIT_KEY_MESSAGE:
            OsdDispDisableOsd();
            break;

        default:
            break;
    }
}
//--------------------------------------------------
// Description  : Hotkey Mute Process
// Input Value  : None
// Output Value : None
//--------------------------------------------------
void MHotKeyMute(void)
{
	if(GET_KEYMESSAGE() == _MUTE_KEY_MESSAGE)
	{
		SET_KEYMESSAGE(_RIGHT_KEY_MESSAGE);
	}
	
    switch(GET_KEYMESSAGE())
    {
        case _RIGHT_KEY_MESSAGE:
        case _LEFT_KEY_MESSAGE:
            OsdDispHotKeyOptionMenuSwitch(_HOTKEY_MUTE);
            ScalerTimerReactiveTimerEvent(SEC(_OSD_DATA_SAVE_TIME), _USER_TIMER_EVENT_SAVE_USER_DATA_MSG);
            break;

        case _MENU_KEY_MESSAGE:
        case _EXIT_KEY_MESSAGE:
            OsdDispDisableOsd();
            break;

        default:
            break;
    }
}
//--------------------------------------------------
// Description  : Hotkey Gamma Process
// Input Value  : None
// Output Value : None
//--------------------------------------------------
void MHotKeyGamma(void)
{	
    switch(GET_KEYMESSAGE())
    {
        case _RIGHT_KEY_MESSAGE:
        case _LEFT_KEY_MESSAGE:
            OsdDispHotKeyOptionMenuSwitch(_HOTKEY_GAMMA);
            ScalerTimerReactiveTimerEvent(SEC(_OSD_DATA_SAVE_TIME), _USER_TIMER_EVENT_SAVE_USER_DATA_MSG);
            break;

        case _MENU_KEY_MESSAGE:
        case _EXIT_KEY_MESSAGE:
            OsdDispDisableOsd();
            break;

        default:
            break;
    }
}
//--------------------------------------------------
// Description  : Hotkey Freeze Process
// Input Value  : None
// Output Value : None
//--------------------------------------------------
void MHotKeyFreeze(void)
{	
    switch(GET_KEYMESSAGE())
    {
        case _RIGHT_KEY_MESSAGE:
        case _LEFT_KEY_MESSAGE:
            OsdDispHotKeyOptionMenuSwitch(_HOTKEY_FREEZE);
            ScalerTimerReactiveTimerEvent(SEC(_OSD_DATA_SAVE_TIME), _USER_TIMER_EVENT_SAVE_USER_DATA_MSG);
            break;

        case _MENU_KEY_MESSAGE:
        case _EXIT_KEY_MESSAGE:
            OsdDispDisableOsd();
            break;

        default:
            break;
    }
}
//--------------------------------------------------
// Description  : Hotkey Freeze Process
// Input Value  : None
// Output Value : None
//--------------------------------------------------
void MHotKeyLightBoxProcess(void)
{	
    switch(GET_KEYMESSAGE())
    {
        case _RIGHT_KEY_MESSAGE:
        case _LEFT_KEY_MESSAGE:
            OsdDispHotKeyOptionMenuSwitch(_HOTKEY_LIGHTBOX);
            ScalerTimerReactiveTimerEvent(SEC(_OSD_DATA_SAVE_TIME), _USER_TIMER_EVENT_SAVE_USER_DATA_MSG);
            break;

        case _MENU_KEY_MESSAGE:
        case _EXIT_KEY_MESSAGE:
			if(GET_OSD_LIGHTBOXMODE_STATUS() == _ON)
			{
			    ScalerTimerCancelTimerEvent( _USER_TIMER_EVENT_OSD_DISABLE);
			    SET_OSD_STATE(_MENU_NONE);
                OsdFuncClearOsd(ROW(0), COL(0), WIDTH(_OSD_HOTKEY_MENU_WIDTH), HEIGHT(_OSD_HOTKEY_MENU_HEIGHT));
			    //ScalerOsdChange1BitColor(ROW(_OSD_MAP_B_ROW_OFFSET), COL(0), LENGTH(_OSD_HOTKEY_MENU_WIDTH), HEIGHT(_OSD_HOTKEY_MENU_HEIGHT), FG_COLOR(_CP_BG), BG_COLOR(_CP_BG));
				OsdFuncCloseWindow(_OSD_HOTKEY_TITLE_WIN);
				OsdFuncCloseWindow(_OSD_HOTKEY_ITEM_WIN);
			}
			else
			{
			    OsdDispDisableOsd();
			}
            break;

        default:
            break;
    }
}

code void (*OperationTable[])(void) =
{
    MenuNone,

    //MainMenu
    MenuMainColor,
    MenuMainFunction,
    MenuMainOSD,
    MenuMainAudio,
    MenuMainServiceLevel2,
    MenuMainAnalog,

    //Color Page
    MColorPageBrightnessProc,
    MColorPageContrastProc,
    MColorPageBacklightProc,
    MColorPageColorTempProc,
    MColorPageGammaProc,

    //ColorTemp Sub Page
    MColorTempSubPageColorTempProc,
    MColorTempSubPageRedProc,
    MColorTempSubPageGreenProc,
    MColorTempSubPageBlueProc,

	//Function Page
    MFunctionPageAspectRatioProc,
    MFunctionPageOverScanProc,
    MFunctionPageDispRotateProc,
    MFunctionPageDispCloneProc,
    
	//OSD Page
	MOSDPageHPostionProc,
    MOSDPageVPostionProc,
    MOSDPageTransparencyProc,
    MOSDPageLanugageProc,
    MOSDPageRotateProc,
    MOSDPageResetProc,

    //Audio Page
    MAudioPageVolumeProc,
    MAudioPageMuteProc,
    MAudioPageAudioSourceProc,

    //ServiceLevel2 Page
    MenuServiceLevel2Page1,
    MenuServiceLevel2Page2,

    //Analog Page    
	MAnalogPageAutoAdjustProc,
	MAnalogPageHPostionProc,
	MAnalogPageVPostionProc,
	MAnalogPageClockProc,
	MAnalogPagePhaseProc,

	//ServiceLevel2 Page 1
	MServiceLevel2Page1HueProc,
	MServiceLevel2Page1SaturationProc,
	MServiceLevel2Page1SharpnessProc,
	MServiceLevel2Page1PCMProc,
	MServiceLevel2Page1HDRModeProc,

	//ServiceLevel2 Page 2
	MServiceLevel2Page2FreezeProc,
	MServiceLevel2Page2DPMstProc,

	MHotKeySource,
	MHotKeyBacklight,
	MHotKeyVolume,
	MHotKeyBrightness,
	MHotKeyContrast,
	MHotKeyMute,
	MHotKeyGamma,
    MHotKeyFreeze,
    MHotKeyLightBoxProcess,
};

#endif//#if(_OSD_TYPE == _KEC_OSD)
